Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to delete a vector layer when a user pans or zooms a map? I saw in the documentation that there is a function called onMapResize. Can this also be used to detect a pan change?

I want to delete a point if the map is panned or zoomed and tried using it in the following way (which does not work):

map.OpenLayers.vectorLayer.onMapResize(console.log('map was moved'))
//use removeAllFeatures() to remove vector points
share|improve this question
up vote 7 down vote accepted

Vadim is right. you can do it with registering map moveend and zoomend events."moveend", map, function(){
     var lyr = map.getLayersByName('vectorLayer')[0];
});"zoomend", map, function(){
     var lyr = map.getLayersByName('vectorLayer')[0];

i hope it helps you...

share|improve this answer

See the map events.

You want moveend and zoomend.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.