+ },
+
+ parseHash: function(hash) {
+ if (hash.indexOf('#') === 0) {
+ hash = hash.substr(1);
+ }
+ hash = querystring.parse(hash);
+ var args = L.Hash.parseHash(hash.map || '') || {};
+ if (hash.layers) args.layers = hash.layers;
+ return args;
+ },
+
+ formatHash: function(args) {
+ 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;