Add layers code to share link
This commit is contained in:
parent
e96a64ca9c
commit
c3cdd4b5d7
3 changed files with 13 additions and 34 deletions
|
@ -114,6 +114,10 @@ function updatelinks(loc, zoom, layers, bounds, object) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function minZoomAlert() {
|
||||||
|
alert(I18n.t("javascripts.site." + name + "_zoom_alert")); return false;
|
||||||
|
}
|
||||||
|
|
||||||
function getShortUrl(map) {
|
function getShortUrl(map) {
|
||||||
return (window.location.hostname.match(/^www\.openstreetmap\.org/i) ?
|
return (window.location.hostname.match(/^www\.openstreetmap\.org/i) ?
|
||||||
'http://osm.org/go/' : '/go/') +
|
'http://osm.org/go/' : '/go/') +
|
||||||
|
@ -129,14 +133,11 @@ function getUrl(map) {
|
||||||
querystring.stringify({
|
querystring.stringify({
|
||||||
lat: center.lat,
|
lat: center.lat,
|
||||||
lon: center.lng,
|
lon: center.lng,
|
||||||
zoom: zoom
|
zoom: zoom,
|
||||||
|
layers: map.getLayersCode()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function minZoomAlert() {
|
|
||||||
alert(I18n.t("javascripts.site." + name + "_zoom_alert")); return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Called to create a short code for the short link.
|
// Called to create a short code for the short link.
|
||||||
function makeShortCode(map) {
|
function makeShortCode(map) {
|
||||||
var zoom = map.getZoom(),
|
var zoom = map.getZoom(),
|
||||||
|
@ -175,6 +176,12 @@ function makeShortCode(map) {
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// generate a cookie-safe string of map state
|
||||||
|
function cookieContent(map) {
|
||||||
|
var center = map.getCenter().wrap();
|
||||||
|
return [center.lng, center.lat, map.getZoom(), map.getLayersCode()].join('|');
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Forms which have been cached by rails may have the wrong
|
* Forms which have been cached by rails may have the wrong
|
||||||
* authenticity token, so patch up any forms with the correct
|
* authenticity token, so patch up any forms with the correct
|
||||||
|
|
|
@ -169,36 +169,10 @@ $(document).ready(function () {
|
||||||
initializeNotes(map);
|
initializeNotes(map);
|
||||||
});
|
});
|
||||||
|
|
||||||
function getMapBaseLayerId(map) {
|
|
||||||
for (var i in map._layers) { // TODO: map.eachLayer
|
|
||||||
var layer = map._layers[i];
|
|
||||||
if (layer.options && layer.options.keyid) {
|
|
||||||
return layer.options.keyid;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function getMapLayers(map) {
|
|
||||||
var layerConfig = '';
|
|
||||||
for (var i in map._layers) { // TODO: map.eachLayer
|
|
||||||
var layer = map._layers[i];
|
|
||||||
if (layer.options && layer.options.code) {
|
|
||||||
layerConfig += layer.options.code;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return layerConfig;
|
|
||||||
}
|
|
||||||
|
|
||||||
// generate a cookie-safe string of map state
|
|
||||||
function cookieContent(map) {
|
|
||||||
var center = map.getCenter().wrap();
|
|
||||||
return [center.lng, center.lat, map.getZoom(), getMapLayers(map)].join('|');
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateLocation() {
|
function updateLocation() {
|
||||||
updatelinks(this.getCenter().wrap(),
|
updatelinks(this.getCenter().wrap(),
|
||||||
this.getZoom(),
|
this.getZoom(),
|
||||||
getMapLayers(this),
|
this.getLayersCode(),
|
||||||
this.getBounds().wrap(), {});
|
this.getBounds().wrap(), {});
|
||||||
|
|
||||||
var expiry = new Date();
|
var expiry = new Date();
|
||||||
|
|
|
@ -58,8 +58,6 @@ L.OSM.share = function (options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function update() {
|
function update() {
|
||||||
var center = map.getCenter().wrap();
|
|
||||||
var layers = getMapLayers(map);
|
|
||||||
$input.val(
|
$input.val(
|
||||||
options.short ? options.getShortUrl(map) : options.getUrl(map)
|
options.short ? options.getShortUrl(map) : options.getUrl(map)
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue