Attaches a map control event to a specified function.
MapControl.AttachEvent(event, function);
Parameters
- event
- The name of the map control event that generates the call.
- function
- The function to run when the event fires, which can be either the name of a function or the function itself.
Remarks
For a list of map control events, see Events.
When the event fires, you can specify either the name of the function to call or the function itself. The following examples show each option.
Example
//Specify the name of a function to call when the onclick event fires:
map.AttachEvent("onclick", OnMapClick);
}
function OnMapClick(e)
{
alert('Latitude = ' + e.view.latlong.latitude + ', Longitude = ' + e.view.latlong.longitude + ', Zoom=' + e.view.zoomLevel);
}
//or specify the function within the AttachEvent method:
map.AttachEvent("onclick", function(e) {
alert('Latitude = ' + e.view.latlong.latitude + ', Longitude = ' + e.view.latlong.longitude + ', Zoom=' + e.view.zoomLevel); }
);