Event that captures mouse action

3 messages Options
Embed this post
Permalink
Langen, Gido

Event that captures mouse action

Reply Threaded More More options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)
Event that captures mouse action

Does anyone know how to capture a mouse click on the map?  I want to do some scale dependent processing and want to capture the scale after zooming in/out.  I need to know the scale right after the zoom in/out, before the map is redrawn. 

Thanks for any insight,
Gido


_______________________________________________
mapguide-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/mapguide-users
Kenneth Skovhede, GEOGRAF A/S

Re: Event that captures mouse action

Reply Threaded More More options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)
There is a function called "OnMapLoading" which you can hijack like this:

//Keep a reference to the original function
GetMapFrame().original_OnMapLoading = GetMapFrame().OnMapLoading;

//Assign a new function
GetMapFrame().OnMapLoading = function(){

    try {
       
       //Place more meaningfull code here :)
        alert("The map is now loading");

    } catch (e)  //Make sure our code does not break the function
    {}

    //Activate the actual MapGuide handler
    original_OnMapLoading();
};

Regards, Kenneth Skovhede, GEOGRAF A/S


Langen, Gido skrev:
Event that captures mouse action

Does anyone know how to capture a mouse click on the map?  I want to do some scale dependent processing and want to capture the scale after zooming in/out.  I need to know the scale right after the zoom in/out, before the map is redrawn. 

Thanks for any insight,
Gido


_______________________________________________ mapguide-users mailing list [hidden email] http://lists.osgeo.org/mailman/listinfo/mapguide-users

_______________________________________________
mapguide-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/mapguide-users
Langen, Gido

RE: Event that captures mouse action

Reply Threaded More More options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)
Event that captures mouse action
Hi Kenneth,
 
Thanks so much for your example.  It worked really well.  I have listed my working copy as further reference. 
Now, I have one more question: I want to associate the functionality with a new command on the toolbar which is easy enough.  The trouble is that the new command can be activated by clicking it but it does not STAY selected like the built-in commands once they have been activated.  So, how can I make a custom command stay selected after it has been activated?
 
Thanks,
Gido
 
 
// Copy original function to new pointer
origOnMapLoadingFunc = parent.parent.mapFrame.OnMapLoading;
 
// Redefine old OnMapLoading function
parent.parent.mapFrame.OnMapLoading = function() {
  // Does somethimg
}
 
// Call "new" functionality
paren.parent.mapFrame.OnMapLoading();
 
//Run old function
origOnMapLoadingFunc();


From: [hidden email] [mailto:[hidden email]] On Behalf Of Kenneth Skovhede, GEOGRAF A/S
Sent: November 4, 2009 00:45
To: MapGuide Users Mail List
Subject: Re: [mapguide-users] Event that captures mouse action

There is a function called "OnMapLoading" which you can hijack like this:

//Keep a reference to the original function
GetMapFrame().original_OnMapLoading = GetMapFrame().OnMapLoading;

//Assign a new function
GetMapFrame().OnMapLoading = function(){

    try {
       
       //Place more meaningfull code here :)
        alert("The map is now loading");

    } catch (e)  //Make sure our code does not break the function
    {}

    //Activate the actual MapGuide handler
    original_OnMapLoading();
};

Regards, Kenneth Skovhede, GEOGRAF A/S


Langen, Gido skrev:

Does anyone know how to capture a mouse click on the map?  I want to do some scale dependent processing and want to capture the scale after zooming in/out.  I need to know the scale right after the zoom in/out, before the map is redrawn. 

Thanks for any insight,
Gido


_______________________________________________ mapguide-users mailing list [hidden email] http://lists.osgeo.org/mailman/listinfo/mapguide-users

_______________________________________________
mapguide-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/mapguide-users