我尝试在Leaflet中显示来自两个不同来源的图块时遇到各种问题:
我的代码:
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);