[mapguide-users] RE: Event that captures mouse action

SriRam007 binod_tripathy at yahoo.co.in
Thu Apr 8 08:08:36 EDT 2010

hi vd,

thanks for giving such a useful site

Just for learning I am trying to show the number of objects selected
Below is my code taken from that site But not working

Not showing the number of objects selected in alert box 

///////****************************************/Handling viewer
//Function variable to store the original OnSelectionChanged
var origOnSelectionChanged = null;

//Our custom selection handler
function MySelectionHandler()
    //This is important. We don't want to replace the original function,
    //we want to attach our code into the execution sequence. So we call the
    //function first.

    //Now our code goes here. For our example, we'll just show the number of
objects selected.
    var count = viewerFrame.GetMapFrame().GetSelectedCount();
    alert(count + " features selected");
window.onload = function() 
    //Timer variable
    var timer; 

    // This is our "watch" function. What we are doing here is 
    // repeatedly checking the mapInit value of the Map Frame. When
    // mapInit is true, then the map has been loaded.
    var watch = function() 
        // What we are doing here is attempting to access the mapInit
        // variable of the Map frame. The reason the code is in a try-catch
        // is because chances are that this code access the DOM
        // of the map frame before its DOM has been initialized.
        try {
            var mapFrame = viewerFrame.mapFrame;
                // Remove the timer so this watch function stops executing
                // Replace the OnSelectionChanged function with our own
                // It is safe to do this now because the DOM for the map
frame is fully initialized.
                // Store old function
                origOnSelectionChanged =
mapFrame.OnSelectionChanged;////Here not getting anything "Undefind" showing
                // Now replace with our own.
                mapFrame.OnSelectionChanged = MySelectionHandler;
        catch(e) {
    // Start the "watching" process. We basically invoke the watch function 
    // every 200ms until the map has been loaded.
    timer = setInterval(watch, 200);
///////****************************************/Handling viewer

what might be the problem Please help me

View this message in context: http://n2.nabble.com/Event-that-captures-mouse-action-tp3939442p4870628.html
Sent from the MapGuide Users mailing list archive at Nabble.com.

More information about the mapguide-users mailing list