2015-05-25 53 views

回答

0

您可以設置一個minZoom屬性來避免這種情況。

喜歡的東西:

var map = L.map('map', { 
    center: [51.505, -0.09], 
    minZoom: 4, 
    zoom: 13 
}); 

Docs Reference

編輯:也許我誤解你的問題。

要限制地圖視圖使用指定的界限:

map.setMaxBounds(LatLngBounds); 

setMaxBounds Reference

更具體地說:

map.setMaxBounds(L.latLngBounds(
    L.latLng(85, -180),  
    L.latLng(-85, 180)  
)); 
0

我懷疑這是正常的,我不相信Leaflet試圖在高變焦狀態下複製標記。

你可以嘗試啓用map.worldCopyJump,這聽起來像它可能適用於你的目的:

啓用該選項後,當您移動到另一個世界的 「複製」和無縫地圖的軌道跳到原始的一個,所以 所有覆蓋像標記和矢量圖層仍然可見。

如果失敗,請嘗試限制minZoom和/或設置maxBoundslike in this example

var southWest = L.latLng(40.712, -74.227), 
    northEast = L.latLng(40.774, -74.125), 
    bounds = L.latLngBounds(southWest, northEast); 

var map = L.map('map', { 
    // set that bounding box as maxBounds to restrict moving the map 
    // see full maxBounds documentation: 
    // http://leafletjs.com/reference.html#map-maxbounds 
    maxBounds: bounds, 
    maxZoom: 19, 
    minZoom: 10 
}); 

// zoom the map to that bounding box 
map.fitBounds(bounds);