I was wondering if there was a way to call an event when the map changes in any way such as a pan or zoom. I would like to have a box that keeps track of the current map scale but can't quite figure how to implement this. Also, it would be nice if instead of displaying the X and Y coords inside of the map object if there was a way to take the Mouse Over event and tie it up to a text box or label or something but I realize at least the latter will need to be javascript.
Ability to call an event on Map Change?
Nelson,
In the existing version (3.0.131), we have a client side event "extentChanged" which will be raised whenever the current extent changed. I’m glad to tell you that we will have a server side CurrentExchanged event in the upcoming version (release around 22rd, Feb).
Here is an example how to show the current scale in a div called “scaleDiv” with the current version.
var OnExtentChanged = function(map) {
$get('scaleDiv').innerHTML = map.getScale().toString();
}
You can also make a postback and deal with the event in server part. To do that please use the following code and implement the IPostBackEventHandler interface on the page:
var loaded = false;
var OnExtentChanged = function(map) {
if (!loaded) loaded = true;
else __doPostBack('__Page', null);
}
Also here is the solution how to bind lon/lat info on other box instead of within the map Control. Let’s say there is a DIV with the Id of “lonlatDiv”, here is how to put the lon/lat info within it.
var OnMapCreated = function(map) {
map.events.register('mousemove', map, function(evt) {
$get('lonlatDiv').innerHTML = map.getLonLatFromPixel(evt.xy).toString();
});
}
Thanks,
Ben
300-Scripts.txt (635 Bytes)