gpt4 book ai didi

javascript - 使用 maxbounds 时,Leaflet map 会无限移动

转载 作者:行者123 更新时间:2023-11-28 04:03:16 25 4
gpt4 key购买 nike

我创建了一个 crs 传单 map ,并尝试将其 maxbounds 设置为 crs 图像的边界。当我添加 maxbounds attr 时,有三个传单事件不断无限触发,导致 map 无限移动。这些是事件:

leafletDirectiveMap.move
leafletDirectiveMap.movestart
leafletDirectiveMap.moveend

这是我的代码。我正在使用传单 Angular Directive(指令)

  angular.module('pyvMap').controller('mainCtrl', [ '$scope', 'leafletData', 'leafletBoundsHelpers', function($scope, leafletData, leafletBoundsHelpers) {

var mapMinZoom = 2;
var mapMaxZoom = 6;
var maxBounds = leafletBoundsHelpers.createBoundsFromArray([[0,241.59375], [-132.65625, 0]]);

angular.extend($scope, {
defaults: {
maxZoom: mapMaxZoom,
minZoom: mapMinZoom,
zoomControl: false,
crs: 'Simple',
attributionControl: false,
detectRetina: true,
tileLayer: "http://d30jy4vw1d2n56.cloudfront.net/tiles/{z}/{x}/{y}.png",
tileLayerOptions: {
minZoom: mapMinZoom,
maxZoom: mapMaxZoom,
// bounds: maxBounds,
opacity: 0.9,
// reuseTiles: true,
continuousWorld: true,
noWrap: true,
tileSize:256,
crs: 'Simple',
detectRetina: true,
},
},
center: {
zoom: 2
},
maxBounds: maxBounds
});}]);

HTML:

<leaflet  center="center"  maxBounds="maxBounds"  defaults="defaults"></leaflet>

谢谢!

最佳答案

一次widthheight属性被添加到 <leaflet>根据需要标记,您的问题看起来无法重现,无论是否使用 Leaflet 版本 0.7.71.2.0 :

https://plnkr.co/edit/iqiz29Jmz2WOgaNeNZIv?p=preview

关于javascript - 使用 maxbounds 时,Leaflet map 会无限移动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46912471/

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