0

我在尝试在 Leaflet 中显示来自两个不同来源的图块时遇到了各种问题:

  • 1:第一个视图与我定义的中心不匹配,但是如果我移动窗口,地图的中心会发生变化并且它会正确居中。我不知道为什么传单会这样做,因为它只适用于一个瓷砖源
  • 2:当我从一层切换到另一层时,什么也没有发生
  • 3:不是所有的数据都在加载,即使是在线瓦片服务器。

我的代码:

var mapOnlineUrl = 'http://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png';
var mapOfflineUrl = 'data/tiles/{z}/{x}/{y}.png';

var onlineTile = L.tileLayer(mapOnlineUrl, {attribution: mapAttribution});
var offlineTile = L.tileLayer(mapOfflineUrl, {attribution: mapAttribution});

var map = L.map('map', {
    center: [46.5, 2.9],
    zoom: 4,
    minZoom: 4,
    maxZoom: 8,
    /* fixing tap http://leafletjs.com/reference.html#map-tap */
    tap: true,
    /* layers */
    layers: [onlineTile, offlineTile, myMarkerSet, MyOtherMarkerSet],
    /* attribution */
    attributionControl: false,
    /* zoom params */
    scrollWheelZoom: false,
    boxZoom: false,
    /* keyboard */
    keyboard: false
});
L.control.attribution({position: 'bottomright'}).addTo(map);
L.control.scale({position: 'bottomleft', imperial: false}).addTo(map);

// ADD GEOJSON'S LAYERS
// groups
var tiles = {
    "online data": onlineTile,
    "offline data": offlineTile
};
L.control.layers(tiles, markers, {collapsed: true, autoZIndex: false}).addTo(map);
4

0 回答 0