Javascript删除缩小范围

时间:2014-08-05 09:35:04

标签: javascript leaflet

我在Leaflet中做了一个简单的地图。当用户从下拉列表中选择区域时,将出现使用绑定方法的矩形框。当地图上的缩放小于10时我想要做什么我想要删除该区域的矩形。这里有一些代码可以帮助您理解

这创建了矩形并缩放到区域

function bound(bounds) {
var bounds;

L.rectangle(bounds, { weight: 1.0, color: "blue" }).addTo(map);
// zoom the map to the rectangle bounds
map.fitBounds(bounds);

}

这是一个功能,为边界函数添加坐标

  function Galway() {
var bounds = [[52.9959, -10.3357], [53.4431, -8.8602]];
// create an orange rectangle
bound(bounds);
 }

在缩小小于10时,我希望边界消失

1 个答案:

答案 0 :(得分:0)

在地图上使用eventlistener:

  map.on('zoomend', function() {
        if (map.getZoom() < 10){
             // remove bounds here, set default bounds or whatever you need to do
          }
        });
相关问题