gpt4 book ai didi

javascript - 传单小 map 滚轮缩放禁用

转载 作者:行者123 更新时间:2023-11-28 05:17:08 24 4
gpt4 key购买 nike

我在 Leaflet Minimap 中禁用滚轮缩放时遇到问题。我根据 https://github.com/Norkart/Leaflet-MiniMap/pull/95 使用 centerFixed 和 zoomLevelFixed 选项实例化小 map 。但我仍然可以用滚轮缩放;虽然平移是禁用的。

下面是代码

    <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<link rel="stylesheet" href="fullscreen.css" />
<!-- 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"
type="text/javascript"></script>

<!-- Leaflet Plugins -->
<link rel="stylesheet" href="Control.MiniMap.css" />
<script src="Control.MiniMap.js" type="text/javascript"></script>

</head>

<body>
<div id="map" ></div>

<script type="text/javascript">

var map = new L.Map('map', { scrollWheelZoom: false});
var osmUrl='http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
var osmAttrib='Map data &copy; OpenStreetMap contributors';
var osm = new L.TileLayer(osmUrl, {/*minZoom: 5, maxZoom: 18,*/ attribution: osmAttrib});
map.addLayer(osm);
map.setView(new L.LatLng(59.92448055859924, 10.758276373601069),10);

//Plugin magic goes here! Note that you cannot use the same layer object again, as that will confuse the two map controls
var osm2 = new L.TileLayer(osmUrl, {/*minZoom: 0, maxZoom: 13,*/ attribution: osmAttrib });


var miniMap = new L.Control.MiniMap(osm2,
{ position: "topright",
centerFixed: [40.7842, -73.9919],
toggleDisplay: true,
zoomLevelFixed: true
}).addTo(map);
</script>
</body>
</html>

我感谢解决此问题的任何指导。谢谢!

最佳答案

我想你应该使用 disable 而不是 false

    map.scrollWheelZoom.disable();

关于javascript - 传单小 map 滚轮缩放禁用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43904358/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com