我创建了一个crs传单地图,我试图将其maxbounds设置为crs图像的边界。 当我添加maxbounds attr时,有三个leaflet事件会无限地触发,这会导致地图无限移动。 这些是事件:
leafletDirectiveMap.move
leafletDirectiveMap.movestart
leafletDirectiveMap.moveend
这是我的代码。我正在使用传单角度指令
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>
谢谢!
答案 0 :(得分:0)
根据需要将width
和height
属性添加到<leaflet>
标记后,无论是使用Leaflet版本0.7.7
还是{{1},您的问题都不具有可重现性}: