return url;
},
- mapParams: function (search) {
- var params = {}, mapParams = {}, bounds, loc;
+ params: function(search) {
+ var params = {};
search = (search || window.location.search).replace('?', '').split(/&|;/);
params[key] = decodeURIComponent(val);
}
+ return params;
+ },
+
+ mapParams: function (search) {
+ var params = OSM.params(search), mapParams = {}, bounds, loc;
+
if (params.mlon && params.mlat) {
mapParams.marker = true;
mapParams.mlon = parseFloat(params.mlon);
var hash = OSM.parseHash(location.hash);
// Decide on a map starting position. Various ways of doing this.
- if (hash.lat && hash.lon) {
+ if (hash.center) {
mapParams.lon = hash.center.lng;
mapParams.lat = hash.center.lat;
mapParams.zoom = hash.zoom;
mapParams.object_zoom = false;
} else if (bounds) {
+ mapParams.lon = bounds.getCenter().lng; // Not used by main map, but
+ mapParams.lat = bounds.getCenter().lat; // are used by iD/Potlatch.
mapParams.bounds = bounds;
mapParams.object_zoom = false;
} else if (params.lon && params.lat) {
},
formatHash: function(args) {
+ var center, zoom, layers;
+
if (args instanceof L.Map) {
- args = {
- lat: args.getCenter().lat,
- lon: args.getCenter().lng,
- zoom: args.getZoom(),
- layers: args.getLayersCode()
- };
+ center = args.getCenter();
+ zoom = args.getZoom();
+ layers = args.getLayersCode();
+ } else {
+ center = L.latLng(args.lat, args.lon);
+ zoom = args.zoom;
+ layers = args.layers || '';
}
- var precision = zoomPrecision(args.zoom),
- hash = '#map=' + args.zoom +
- '/' + args.lat.toFixed(precision) +
- '/' + args.lon.toFixed(precision);
+ center = center.wrap();
+ layers = layers.replace('M', '');
- if (args.layers) {
- args.layers = args.layers.replace('M', '');
- }
+ var precision = zoomPrecision(zoom),
+ hash = '#map=' + zoom +
+ '/' + center.lat.toFixed(precision) +
+ '/' + center.lng.toFixed(precision);
- if (args.layers) {
- hash += '&layers=' + args.layers;
+ if (layers) {
+ hash += '&layers=' + layers;
}
return hash;