我无法强制我的传单地图仅使用整数缩放级别。只要我只使用 -/+ 控制按钮就可以了,但只要我使用鼠标滚轮或 map.fitBounds(some polygon) 之类的功能,我总是会以分数缩放级别结束。
这对我来说很糟糕,因为我使用 0 到 17 级的图块,当我最终得到两个级别之间的分数缩放级别时,比如 10.5,图块被缩放和模糊。
文档说 zoomSnap 和 zoomDelta 的默认值为 1。所以我不明白为什么我最终会得到分数缩放级别。我怎样才能防止这种情况?
我正在使用这些
<!-- Leaflet -->
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.0.1/dist/leaflet.css" />
<script src="https://unpkg.com/leaflet@1.0.1/dist/leaflet.js"></script>
<!-- L.esri for Leaflet -->
<script src="https://unpkg.com/esri-leaflet@2.0.4"></script>
<!-- Elevation plugin for Leaflet -->
<link rel="stylesheet" href="/app/libs/leaflet-elevation/dist/leaflet.elevation-0.0.4.css" />
<script src="https://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<!--<script src="app/libs/leaflet-elevation/dist/leaflet.elevation-0.0.4.min.js"></script>-->
<script src="/app/libs/leaflet-elevation/dist/leaflet.elevation-0.0.4.src.js"></script>
<!-- Marker Cluster plugin for Leaflet -->
<link rel="stylesheet" type="text/css" href="https://unpkg.com/leaflet.markercluster@1.0.0/dist/MarkerCluster.Default.css">
<link rel="stylesheet" type="text/css" href="https://unpkg.com/leaflet.markercluster@1.0.0/dist/MarkerCluster.css">
<script src="https://unpkg.com/leaflet.markercluster@1.0.0/dist/leaflet.markercluster.js"></script>
<!-- zoomhome plugin for Leaflet -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css"/>
<link rel="stylesheet" href="/app/libs/leaflet-zoomhome/leaflet.zoomhome.css"/>
<script src="/app/libs/leaflet-zoomhome/leaflet.zoomhome.js"></script>
这是我初始化地图的方式:
this.map = L.map(this.config.domNode, {
center: [50.13466432216696, -72.72949218750001],
zoom: 6,
zoomSnap: 1,
zoomDelta: 1,
zoomControl: false,
minZoom: 3,
maxZoom: 17,
scrollWheelZoom: this.config.scrollWheelZoom,
wheelDebounceTime: 20,
wheelPxPerZoomLevel: 50
});
L.Control.zoomHome({ position: 'topright' }).addTo(this.map);