如何根据缩放级别加载图层? [英] How to load layers depending on zoom level?
问题描述
我想控制OpenLayers的缩放.
I want to control the zoom in OpenLayers.
当缩放为3时,我要加载KML1;当缩放为4时,我要加载KML2.
When the zoom is 3 I want to load KML1 and when the zoom is 4 i want to load KML2.
您能告诉我如何控制缩放事件吗?
Could you please advise me how I can control the zoom-event?
推荐答案
一种实现此目的的方法是使用类似
a way to accomplish that is to register an event on event "zoomend" on your map with something like
map.events.register(type, obj, listener);
您可以在此处找到更多信息: http://dev.openlayers.org/releases/OpenLayers-2.11/doc/apidocs/files/OpenLayers/Map-js.html
You can find more info there: http://dev.openlayers.org/releases/OpenLayers-2.11/doc/apidocs/files/OpenLayers/Map-js.html
也许您还应该同时加载两个kml,然后根据缩放级别隐藏/显示正确的图层.
Maybe you should also load both of your kml and then hide / show the correct layer depend on the zoom level.
这篇关于如何根据缩放级别加载图层?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!