+ }
+
+ function removeNewNoteMarker() {
+ removeHalo();
+ if (newNoteMarker) map.removeLayer(newNoteMarker);
+ newNoteMarker = null;
+ }
+
+ page.pushstate = page.popstate = function (path) {
+ OSM.loadSidebarContent(path, function () {
+ page.load(path);
+ });
+ };
+
+ page.load = function (path) {
+ if (addNoteButton.hasClass("disabled")) return;
+ if (addNoteButton.hasClass("active")) return;
+
+ addNoteButton.addClass("active");
+
+ map.addLayer(noteLayer);
+
+ var params = Qs.parse(path.substring(path.indexOf("?") + 1));
+ var markerLatlng;
+
+ if (params.lat && params.lon) {
+ markerLatlng = L.latLng(params.lat, params.lon);
+ } else {
+ markerLatlng = map.getCenter();
+ }
+
+ map.panInside(markerLatlng, {
+ padding: [50, 50]
+ });
+
+ addNewNoteMarker(markerLatlng);