}
for (i = 0; i < ((zoom + 8) % 3); ++i) str += "-";
- /*
- * Called to interlace the bits in x and y, making a Morton code.
- */
+ // Called to interlace the bits in x and y, making a Morton code.
function interlace(x, y) {
x = (x | (x << 8)) & 0x00ff00ff;
x = (x | (x << 4)) & 0x0f0f0f0f;
var marker;
var params = OSM.mapParams();
- map = L.map("map", {
+ var map = L.map("map", {
zoomControl: false,
layerControl: false
});
L.control.scale().addTo(map);
- map.on("moveend layeradd layerremove", updateLocation);
+ map.on('moveend layeradd layerremove', updateLocation);
if (!params.object_zoom) {
if (params.bbox) {
marker = L.marker(centre, {icon: getUserIcon()}).addTo(map);
});
- function updateLocation() {
+ // generate a cookie-safe string of map state
+ function cookieContent(map) {
var center = map.getCenter().wrap();
- var zoom = map.getZoom();
- var layers = getMapLayers();
- var extents = map.getBounds().wrap();
+ return [center.lng, center.lat, map.getZoom(), getMapLayers(map)].join('|');
+ }
- updatelinks(center, zoom, layers, extents, params.object);
+ function updateLocation() {
+ updatelinks(map.getCenter().wrap(),
+ map.getZoom(),
+ getMapLayers(this),
+ map.getBounds().wrap(),
+ params.object);
var expiry = new Date();
expiry.setYear(expiry.getFullYear() + 10);
- $.cookie("_osm_location", [center.lng, center.lat, zoom, layers].join("|"), {expires: expiry});
+ $.cookie("_osm_location", cookieContent(map), { expires: expiry });
}
function remoteEditHandler() {
}
}
-function getMapLayers() {
- var layerConfig = "";
+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) {
this._uiPane = this.options.uiPane;
+ this._map = map;
+
var h2 = L.DomUtil.create('h2', '', this._uiPane);
h2.innerHTML = I18n.t('javascripts.share.title');
},
_update: function (e) {
- var center = map.getCenter().wrap();
- var layers = getMapLayers();
- this._linkInput.value = this.options.getUrl(map);
+ var center = this._map.getCenter().wrap();
+ var layers = getMapLayers(this._map);
+ this._linkInput.value = this.options.getUrl(this._map);
},
_toggle: function() {