Fix multi layers support
This commit is contained in:
parent
cc5da47cad
commit
2188183d3f
1 changed files with 9 additions and 9 deletions
|
|
@ -25,7 +25,7 @@
|
||||||
var zoom = parseInt(mapsArgs[0], 10),
|
var zoom = parseInt(mapsArgs[0], 10),
|
||||||
lat = parseFloat(mapsArgs[1]),
|
lat = parseFloat(mapsArgs[1]),
|
||||||
lon = parseFloat(mapsArgs[2]),
|
lon = parseFloat(mapsArgs[2]),
|
||||||
layer = decodeURIComponent(mapsArgs[3]);
|
layers = decodeURIComponent(mapsArgs[3]).split('-');
|
||||||
additional = args[1];
|
additional = args[1];
|
||||||
if (isNaN(zoom) || isNaN(lat) || isNaN(lon)) {
|
if (isNaN(zoom) || isNaN(lat) || isNaN(lon)) {
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -33,7 +33,7 @@
|
||||||
return {
|
return {
|
||||||
center: new L.LatLng(lat, lon),
|
center: new L.LatLng(lat, lon),
|
||||||
zoom: zoom,
|
zoom: zoom,
|
||||||
layer: layer,
|
layers: layers,
|
||||||
additional: additional
|
additional: additional
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -46,15 +46,14 @@
|
||||||
var center = map.getCenter(),
|
var center = map.getCenter(),
|
||||||
zoom = map.getZoom(),
|
zoom = map.getZoom(),
|
||||||
precision = Math.max(0, Math.ceil(Math.log(zoom) / Math.LN2)),
|
precision = Math.max(0, Math.ceil(Math.log(zoom) / Math.LN2)),
|
||||||
layer = null;
|
layers = [];
|
||||||
|
|
||||||
var options = this.options;
|
var options = this.options;
|
||||||
//Check active layer
|
//Check active layer
|
||||||
for(var key in options) {
|
for(var key in options) {
|
||||||
if (options.hasOwnProperty(key)) {
|
if (options.hasOwnProperty(key)) {
|
||||||
if (map.hasLayer(options[key])) {
|
if (map.hasLayer(options[key])) {
|
||||||
layer = encodeURIComponent(key);
|
layers.push(key);
|
||||||
break;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
@ -62,7 +61,7 @@
|
||||||
zoom,
|
zoom,
|
||||||
center.lat.toFixed(precision),
|
center.lat.toFixed(precision),
|
||||||
center.lng.toFixed(precision),
|
center.lng.toFixed(precision),
|
||||||
layer
|
encodeURIComponent(layers.join("-"))
|
||||||
];
|
];
|
||||||
url = "#map=" + params.join("/");
|
url = "#map=" + params.join("/");
|
||||||
if (this.additionalCb != null) {
|
if (this.additionalCb != null) {
|
||||||
|
|
@ -138,9 +137,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
var options = this.options,
|
var options = this.options,
|
||||||
layer = parsed.layer in options ? parsed.layer : Object.keys(options)[0],
|
layers = parsed.layers.length > 0 ? parsed.layers : [Object.keys(options)[0]],
|
||||||
that = this;
|
that = this;
|
||||||
|
|
||||||
//Add/remove layer
|
//Add/remove layer
|
||||||
this.map.eachLayer(function(layer) {
|
this.map.eachLayer(function(layer) {
|
||||||
for (alayer in that.layers) {
|
for (alayer in that.layers) {
|
||||||
|
|
@ -150,7 +148,9 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
that.map.addLayer(options[layer]);
|
layers.forEach(function(element, index, array) {
|
||||||
|
that.map.addLayer(options[element]);
|
||||||
|
});
|
||||||
|
|
||||||
this.isUpdatingHash = false;
|
this.isUpdatingHash = false;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue