I have created a map that contains a two base layers (Google Street Map and Open Street Map). A moveend
event listener is registered to listen for any map movement which would perform a function call to load in new data based on the bounds of the map view port. I realise that the function call is performed even when switching the base layer without causing any map movement. Is there a way to switch the base layer silently?
As requested, the code in brief:
var map;
var gmap_r = new OpenLayers.Layer.Google('Google Street Map');
var osm = new OpenLayers.Layer.OSM('Open Street Map');
var options = {
layers: [gmap_r, osm, markers]
...
};
map = new OpenLayers.Map('map', options);
map.events.register('moveend', map, my_function);
//code above used for triggering a call to my_function upon a map pan or zoom event
The change of base layer unfortunately triggers the above as well.
Best Answer
if you share your code, we can make a good point for you. addition to the
moveend
listener you can chek out OpenLayers.Control.DragPan method for your request.i hope it helps you...