The second part, Working with the Map Extent was published yesterday. The remaining articles in this series will be published this week.
Adding Event Listeners
Removing Event Listeners
You should always remove listeners when your application is being closed to avoid memory leaks. This can be accomplished through the use of the Map.onUnload event in conjunction with dojo.disconnect. The onUnload event is fired when the map is closed, and dojo.disconnect removes the connect between an event and the method being referenced.
Commonly Used Events
The Map object currently has 27 events that can be initiated including onClick, onExtentChange, onLayerAdd, onLoad, onMouseDrag, onMouseWheel, onZoom, onPan and many others. I should point out that it is not necessary to write listener code functions for every single event that can be triggered. You only write event handlers for those events that are necessary for your application. When an event is triggered for which you have not registered and written a handler, the event is simply ignored in the application. Several other objects provide important events including the Layer, GraphicsLayer, and InfoWindow.
This article was written by Eric Pimpler at GeoSpatial Training Services. Geospatial Training Services provide a
range of geoweb courses.