Hello, I'm trying to limit the zoom levels of my OpenLayers application. I want to make max zoom level to be 14 using standard zoom levels (nothing fancy like fractional zooms and resolutions) and that is all. I've read this article: http://trac.osgeo.org/openlayers/wiki/SettingZoomLevels I've tried tons of combinations of maxExtent, minExtent, maxResolution, minResolution, numZoomLevels and so on... the user is always able to go beyond ZL 14 :( Here is my map definition:
asked 20 Jun '12, 18:52 ivanatora retagged 21 Jun '12, 23:18 ikonor |
3 Answers:
For tile based layers you can set zoomOffset and resolutions. See Wiki Restricting the bounds & zoom levels and example Isle of Wight Paths. Setting maxResolution and numZoomLevels along with serverResolutions should also work, see Bing Tiles with a Subset of Resolutions Example. For convenience, I use the serverResolutions array defined in the Bing layer, which corresponds to OSM resolutions (apart from extending to level 21):
answered 21 Jun '12, 23:16 ikonor |
I'd register an event on movestart (which includes zooming) and prevent zooming if the map's zoomlevel is higher than a certain value
I didn't test this, so you propably need to enhance the event handling function answered 21 Jun '12, 09:07 frabron |
I found the simplest way to restrict the maxZoom levels for a XYZ layer was to override the getNumZoomLevels method:
answered 09 Jun '16, 11:48 Vijay Rajbhar |
Okay, the first issue was that the event name is 'movestart', not 'zoomstart'. I've changed that and the handler is firing, but I can't stop the event propagation. I keep getting event.stop is not a function. I tried OpenLayers.Event.stop(e) but that seems to do nothing at all. How to get the event from the handler function? The callback argument seem to contain 2 properties - dom element and object (that is not OpenLayers.Event object) and that is all.