map.attributionControl.setPrefix('');
- new L.Hash(map);
+ map.hash = L.hash(map);
var layers = [
new L.OSM.Mapnik({
})
];
- layers[0].addTo(map);
+ for (var i = layers.length - 1; i >= 0; i--) {
+ if (i === 0 || params.layers.indexOf(layers[i].options.code) >= 0) {
+ map.addLayer(layers[i]);
+ break;
+ }
+ }
+
+ map.noteLayer = new L.LayerGroup();
+ map.noteLayer.options = {code: 'N'};
- map.noteLayer = new L.LayerGroup({code: 'N'});
map.dataLayer = new L.OSM.DataLayer(null);
+ map.dataLayer.options.code = 'D';
$("#sidebar").on("opened closed", function () {
map.invalidateSize();
L.OSM.share({
position: position,
- getShortUrl: getShortUrl,
- getUrl: getUrl,
sidebar: sidebar,
short: true
}).addTo(map);
}).addTo(map);
}
- if (params.layers) {
- var foundLayer = false;
- for (var i = 0; i < layers.length; i++) {
- if (params.layers.indexOf(layers[i].options.code) >= 0) {
- map.addLayer(layers[i]);
- foundLayer = true;
- } else {
- map.removeLayer(layers[i]);
- }
- }
- if (!foundLayer) {
- map.addLayer(layers[0]);
- }
- }
-
if (params.marker) {
L.marker([params.mlat, params.mlon], {icon: getUserIcon()}).addTo(map.markerLayer);
}
if (params.object) {
- addObjectToMap(params.object, map, { zoom: params.object_zoom });
+ map.addObject(params.object, { zoom: params.object_zoom });
}
$("body").on("click", "a.set_position", setPositionLink(map));
}
initializeExport(map);
- initializeBrowse(map);
- initializeNotes(map);
+ initializeBrowse(map, params);
+ initializeNotes(map, params);
});
function updateLocation() {
var expiry = new Date();
expiry.setYear(expiry.getFullYear() + 10);
$.cookie("_osm_location", cookieContent(this), { expires: expiry });
+
+ // Trigger hash update on layer changes.
+ this.hash.onMapMove();
}
function setPositionLink(map) {
}
if (data.type && data.id) {
- addObjectToMap(data, map, { zoom: true, style: { opacity: 0.2, fill: false } });
+ map.addObject(data, { zoom: true, style: { opacity: 0.2, fill: false } });
}
map.markerLayer.clearLayers();