+}
+
+function getMapLayers(map) {
+ var layerConfig = '';
+ for (var i in map._layers) { // TODO: map.eachLayer
+ var layer = map._layers[i];
+ if (layer.options && layer.options.code) {
+ layerConfig += layer.options.code;
+ }
+ }
+ return layerConfig;
+}
+
+// generate a cookie-safe string of map state
+function cookieContent(map) {
+ var center = map.getCenter().wrap();
+ return [center.lng, center.lat, map.getZoom(), getMapLayers(map)].join('|');
+}
+
+function updateLocation() {
+ updatelinks(this.getCenter().wrap(),
+ this.getZoom(),
+ getMapLayers(this),
+ this.getBounds().wrap(), {});
+
+ var expiry = new Date();
+ expiry.setYear(expiry.getFullYear() + 10);
+ $.cookie("_osm_location", cookieContent(this), { expires: expiry });
+}
+
+function setPositionLink(map) {
+ return function(e) {
+ var data = $(this).data(),
+ center = L.latLng(data.lat, data.lon);
+
+ if (data.minLon && data.minLat && data.maxLon && data.maxLat) {
+ map.fitBounds([[data.minLat, data.minLon],
+ [data.maxLat, data.maxLon]]);
+ } else {
+ map.setView(center, data.zoom);
+ }