+ var noteIcons = {
+ "new": L.icon({
+ iconUrl: "<%= image_path 'new_note_marker.png' %>",
+ iconSize: [22, 22],
+ iconAnchor: [11, 11]
+ }),
+ "open": L.icon({
+ iconUrl: "<%= image_path 'open_note_marker.png' %>",
+ iconSize: [22, 22],
+ iconAnchor: [11, 11]
+ }),
+ "closed": L.icon({
+ iconUrl: "<%= image_path 'closed_note_marker.png' %>",
+ iconSize: [22, 22],
+ iconAnchor: [11, 11]
+ })
+ };
+
+ var noteLayer = new L.LayerGroup();
+ var notes = {};
+ var newNote;
+
+ map.on("layeradd", function (e) {
+ if (e.layer == noteLayer) {
+ loadNotes();
+ map.on("moveend", loadNotes);
+ }
+ });
+
+ map.on("layerremove", function (e) {
+ if (e.layer == noteLayer) {
+ map.off("moveend", loadNotes);
+ noteLayer.clearLayers();
+ notes = {};
+ }
+ });
+
+ map.on("popupopen", function (e) {
+ $(e.popup._container).find(".comment").focus();
+ });
+
+ map.on("popupclose", function (e) {
+ if (newNote && e.popup == newNote._popup) {
+ $(newNote).oneTime(10, "removenote", function () {
+ map.removeLayer(newNote);
+ newNote = null;
+ });
+ }
+ });
+
+ if (OSM.STATUS != 'api_offline' && OSM.STATUS != 'database_offline') {
+ map.layersControl.addOverlay(noteLayer, I18n.t("browse.start_rjs.notes_layer_name"));
+
+ if (params.notes) map.addLayer(noteLayer);
+
+ if (params.note) {
+ $.ajax({
+ url: "/api/" + OSM.API_VERSION + "/notes/" + params.note + ".json",
+ success: function (feature) {
+ var marker = updateMarker(notes[feature.properties.id], feature);
+
+ notes[feature.properties.id] = marker;