* view tab and various other links
*/
function updatelinks(loc, zoom, layers, bounds, object) {
- var precision = zoomPrecision(zoom);
- bounds = normalBounds(bounds);
-
- var lat = loc.lat.toFixed(precision),
- lon = (loc.lon || loc.lng).toFixed(precision);
-
- if (bounds) {
- var minlon = bounds.getWest().toFixed(precision),
- minlat = bounds.getSouth().toFixed(precision),
- maxlon = bounds.getEast().toFixed(precision),
- maxlat = bounds.getNorth().toFixed(precision);
- }
+ $(".geolink").each(function(index, link) {
+ var base = link.href.split('?')[0],
+ args = querystring.parse(link.search.substring(1));
- $(".geolink").each(setGeolink);
+ if (bounds && $(link).hasClass("bbox")) args.bbox = normalBounds(bounds).toBBoxString();
+ if (layers && $(link).hasClass("layers")) args.layers = layers;
+ if (object && $(link).hasClass("object")) args[object.type] = object.id;
- function setGeolink(index, link) {
- var base = link.href.split('?')[0],
- qs = link.href.split('?')[1],
- args = querystring.parse(qs);
+ var href = base + '?' + querystring.stringify(args);
if ($(link).hasClass("llz")) {
- $.extend(args, {
- lat: lat,
- lon: lon,
- zoom: zoom
- });
- } else if (minlon && $(link).hasClass("bbox")) {
- $.extend(args, {
- bbox: minlon + "," + minlat + "," + maxlon + "," + maxlat
- });
+ href += OSM.formatHash({lat: loc.lat, lon: loc.lon || loc.lng, zoom: zoom});
}
- if (layers && $(link).hasClass("layers")) args.layers = layers;
- if (object && $(link).hasClass("object")) args[object.type] = object.id;
+ link.href = href;
var minzoom = $(link).data("minzoom");
if (minzoom) {
});
}
}
- link.href = base + '?' + querystring.stringify(args);
- }
+ });
}
// generate a cookie-safe string of map state
},
getUrl: function(marker) {
- var center = this.getCenter(),
- zoom = this.getZoom(),
- precision = zoomPrecision(zoom),
- params = {
- lat: center.lat.toFixed(precision),
- lon: center.lng.toFixed(precision),
- zoom: zoom,
- layers: this.getLayersCode()
- };
+ var precision = zoomPrecision(this.getZoom()),
+ params = { layers: this.getLayersCode() };
if (marker && this.hasLayer(marker)) {
params.mlat = marker.getLatLng().lat.toFixed(precision);
params.mlon = marker.getLatLng().lng.toFixed(precision);
}
- return 'http://' + OSM.SERVER_URL + '/?' + querystring.stringify(params);
+ return 'http://' + OSM.SERVER_URL + '/?' + querystring.stringify(params) +
+ OSM.formatHash({lat: this.getCenter().lat, lon: this.getCenter().lng, zoom: this.getZoom()});
},
getShortUrl: function(marker) {