center = center.wrap();
layers = layers.replace('M', '');
- var precision = zoomPrecision(zoom),
+ var precision = OSM.zoomPrecision(zoom),
hash = '#map=' + zoom +
'/' + center.lat.toFixed(precision) +
'/' + center.lng.toFixed(precision);
}
return hash;
+ },
+
+ zoomPrecision: function(zoom) {
+ return Math.max(0, Math.ceil(Math.log(zoom) / Math.LN2));
+ },
+
+ locationCookie: function(map) {
+ var center = map.getCenter().wrap(),
+ zoom = map.getZoom(),
+ precision = OSM.zoomPrecision(zoom);
+ return [center.lng.toFixed(precision), center.lat.toFixed(precision), zoom, map.getLayersCode()].join('|');
}
};