Select to view content in your preferred language

v1.5 map.onLoad Event not firing using all dynamic layers

1122
2
11-02-2010 05:15 AM
AndrewJones
New Contributor
I have an app that will 90% of the time be using a tiled base mapping service, but there is also an option to use all dynamic services.  Will testing this I have found that the map.onLoad event does not fire when only adding dynamic service layers.

I always thought that it would fire after the first layer has been added?  Does it only work with tiled services? What can I use instead for dynamic if onLoad does not fire?
0 Kudos
2 Replies
TimRourke
New Contributor
Looks like the onLoad event "Fires when the first or base layer has been successfully added to the map." So the first layer of any kind should trigger it.

You could add a tiled layer as a base layer and turn it off. Or you could use the layer onLoad event to check to check a Boolean variable and trigger the map onLoad event if it is false. Then set the Boolean variable to true in the map onLoad event to prevent it from running again. If the API starts behaving again you don't end up running the map onLoad twice.
0 Kudos
AndrewJones
New Contributor
Well, the first layer does not fire the event.  I have a number of dojo connects setup before the layers start getting added and it works with tiled layer.

However, your idea of simply calling map.onLoad myself has solved my issue as I will know if they are all dynamic anyway before hand.

Thanks for the second opinion!
0 Kudos