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

vd vd at plan-online.info
Thu Apr 8 11:08:56 EDT 2010


I think you do not point the viewerFrame (or however you named this frame!!!
this is the top of the ajaxviewer).

 

  _____  

Von: SriRam007 [via OSGeo.org]
[mailto:ml-node+4870628-1747384781-272960 at n2.nabble.com] 
Gesendet: Donnerstag, 8. April 2010 14:09
An: vd
Betreff: RE: Event that captures mouse action

 

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
selection/********************************************************** 
//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,
rather 
    //we want to attach our code into the execution sequence. So we call the
original 
    //function first. 
    origOnSelectionChanged(); 

    //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() 
{ 
//debugger 
    //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 { 
        //debugger 
            var mapFrame = viewerFrame.mapFrame; 
            if(mapFrame.mapInit) 
            { 
  
                // Remove the timer so this watch function stops executing 
                clearInterval(timer); 
                  
                // Replace the OnSelectionChanged function with our own
function. 
                // 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
selection/********************************************************** 


what might be the problem Please help me 



thanks 

  _____  

View message @
http://n2.nabble.com/Event-that-captures-mouse-action-tp3939442p4870628.html

To unsubscribe from RE: Event that captures mouse action, click
< (link removed) 
uaW5mb3w0ODcwMTQ2fDEzOTkxODM0ODk=>  here. 

 


-- 
View this message in context: http://n2.nabble.com/Event-that-captures-mouse-action-tp3939442p4871694.html
Sent from the MapGuide Users mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapguide-users/attachments/20100408/7b99934b/attachment.html


More information about the mapguide-users mailing list