- var precision = zoomPrecision(args.zoom);
- return '#' + args.zoom +
- '/' + args.lat.toFixed(precision) +
- '/' + args.lon.toFixed(precision);
+ if (args instanceof L.Map) {
+ args = {
+ lat: args.getCenter().lat,
+ lon: args.getCenter().lng,
+ zoom: args.getZoom(),
+ layers: args.getLayersCode()
+ };
+ }
+
+ var precision = zoomPrecision(args.zoom),
+ hash = '#map=' + args.zoom +
+ '/' + args.lat.toFixed(precision) +
+ '/' + args.lon.toFixed(precision);
+
+ if (args.layers) {
+ args.layers = args.layers.replace('M', '');
+ }
+
+ if (args.layers) {
+ hash += '&layers=' + args.layers;
+ }
+
+ return hash;