OL 中的地图对象支持多种类型的事件。
这是列表(http://dev.openlayers.org/releases/OpenLayers-2.11/doc/apidocs/files/OpenLayers/Map-js.html)
preaddlayer ==> triggered before a layer has been added.
addlayer ==> triggered after a layer has been added.
preremovelayer ==> triggered before a layer has been removed.
removelayer ==> triggered after a layer has been removed.
changelayer ==> triggered after a layer name change, order change, opacity change, params change, visibility change (due to ==> resolution thresholds) or attribution change (due to extent change).
movestart ==> triggered after the start of a drag, pan, or zoom
move ==> triggered after each drag, pan, or zoom
moveend ==> triggered after a drag, pan, or zoom completes
zoomend ==> triggered after a zoom completes
mouseover ==> triggered after mouseover the map
mouseout ==> triggered after mouseout the map
mousemove ==> triggered after mousemove the map
changebaselayer ==> triggered after the base layer changes
你为什么不将这些事件与类似的东西一起使用:
map.events.register('move', map, function (e) {
$('#tooltip')
.css('top', e.pageY + offsetY)
.css('left', e.pageX + offsetX);
$('#coor').val(e.pageX + ' - ' + e.pageY);
});
map.events.register('movestart', map, function (e) {
$('#tooltip').fadeIn(500);
});
map.events.register('moveend', map, function (e) {
$('#tooltip').fadeOut(500);
});