+ },
+
+ 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) {
+ var center, zoom, layers;
+
+ if (args instanceof L.Map) {
+ center = args.getCenter();
+ zoom = args.getZoom();
+ layers = args.getLayersCode();
+ } else {
+ center = L.latLng(args.lat, args.lon);
+ zoom = args.zoom;
+ layers = args.layers || '';
+ }
+
+ center = center.wrap();
+ layers = layers.replace('M', '');
+
+ var precision = zoomPrecision(zoom),
+ hash = '#map=' + zoom +
+ '/' + center.lat.toFixed(precision) +
+ '/' + center.lng.toFixed(precision);
+
+ if (layers) {
+ hash += '&layers=' + layers;
+ }
+
+ return hash;