OpenLayers: Raise event when map is zoomed or moved by user
Posted
by David Pfeffer
on Stack Overflow
See other posts from Stack Overflow
or by David Pfeffer
Published on 2010-03-09T05:18:08Z
Indexed on
2010/03/09
5:21 UTC
Read the original article
Hit count: 394
I'm using OpenLayers to display OpenStreetMap maps. (Though, I'd assume this should be general enough to work for any map product...)
I'm displaying some very sophisticated vector overlays, and the amount and resolution of the features I'm returning from the server via GeoJSON to overlay has proven too much for many computers.
What I'd like to do now instead is to only send data befitting the resolution of the current zoom, and fitting the current view port. This should be relatively easy to do using the GetResolution
and CalculateBounds
methods on the Map
object. However, I don't know when to call these methods because I can't find a way to register a function to be called when the user pans the map (changing the view port) or zooms the map (changing the resolution and view port).
How can I get a callback when the user pans or zooms the map?
© Stack Overflow or respective owner