[fusion-users] Mapguide Eventhandling with Fusion.

Paul Deschamps pdeschamps at dmsolutions.ca
Wed May 14 13:25:37 EDT 2008


Did you add this in map.js or your supporting application JS file in the
template? doing so would probably fire it in the manor of which you
described. 


In the application template the supporting JS should have: 

window.onload = function(){
  Fusion.initialize();
  Fusion.registerForEvent(Fusion.Event.FUSION_INITIALIZED,
onInitialize);
}

// funsion initialized fire listeners. 
function onInitialize() {
    // get the mapwidget via ID
    var map = Fusion.getMapById('mapArea'); 
    map.registerForEvent(Fusion.Event.MAP_LOADING, mapLoading);
    map.registerForEvent(Fusion.Event.MAP_LOADED, mapIsLoaded);
    map.registerForEvent(Fusion.Event.MAP_RELOADED, mapReloaded);
    map.registerForEvent(Fusion.Event.MAP_ACTIVE_LAYER_CHANGED,
activeLayerChanged);
    map.registerForEvent(Fusion.Event.MAP_SELECTION_ON, selectionOn);
}

// console.log requires  firebug. see. http://www.getfirebug.com/
function mapLoading(){
  console.log("MAP_LOADING");


function mapIsLoaded(){
  console.log("MAP_LOADED");
}

function mapReloaded(){
  console.log("MAP_RELOADED");
}

function activeLayerChanged(){
  console.log("MAP_ACTIVE_LAYER_CHANGED");
}

function selectionOn(){
  console.log("MAP_SELECTION_ON");
}

Hope this helps

Cheers

Paul D. 


-- 
+----------------------------+
| Paul Deschamps             |
| Applications Specialist    |
|                            |
| DM Solutions Group         |
| http://dmsolutions.ca/     |
| P: 613.565.5056 ext 28     |
| F: 613.565.0925            |
+----------------------------+

On Wed, 2008-05-14 at 16:57 +0000, Tómas Guðmundsson wrote:
> Hi all.
> 
> I just conducted a little experiment with the Event Handlers in Map.js
> 
>         map.registerForEvent(Fusion.Event.MAP_LOADING, alert('MAP_LOADING'));
>         map.registerForEvent(Fusion.Event.MAP_LOADED,alert('MAP_LOADED'));
>         map.registerForEvent(Fusion.Event.MAP_RELOADED,alert('MAP_RELOADED'));
> 
> And what I originally thought what would happen that it would give me an alert 
> at first when it was loading, and then when it would load. Then I thought it would
> give me the third alert when i pressed the refresh map button. But, what happened
> was before the map was ready or visible to me, they all loaded consecutively so 
> I got three alerts in a row.
> 
> If anyone can tell me why this is or what the reasons are behind that I would really
> appreciate that. Also if anyone can tell me how to find out when the map is visible,
> after a refresh or after any (first or last time a user) sees the gray background of
> the map itself.
> 
> Regards,
> Tómas.
> _______________________________________________
> fusion-users mailing list
> fusion-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/fusion-users



More information about the fusion-users mailing list