1 OSM.initializeNotesLayer = function (map) {
2 var noteLayer = map.noteLayer,
7 iconUrl: OSM.NEW_NOTE_MARKER,
12 iconUrl: OSM.OPEN_NOTE_MARKER,
17 iconUrl: OSM.CLOSED_NOTE_MARKER,
23 noteLayer.on("add", () => {
25 map.on("moveend", loadNotes);
26 }).on("remove", () => {
27 map.off("moveend", loadNotes);
28 noteLayer.clearLayers();
30 }).on("click", function (e) {
32 OSM.router.route("/note/" + e.layer.id);
36 function updateMarker(old_marker, feature) {
37 var marker = old_marker;
39 marker.setIcon(noteIcons[feature.properties.status]);
41 marker = L.marker(feature.geometry.coordinates.reverse(), {
42 icon: noteIcons[feature.properties.status],
43 title: feature.properties.comments[0].text,
47 marker.id = feature.properties.id;
48 marker.addTo(noteLayer);
53 noteLayer.getLayerId = function (marker) {
59 function loadNotes() {
60 var bounds = map.getBounds();
61 var size = bounds.getSize();
63 if (size <= OSM.MAX_NOTE_REQUEST_AREA) {
64 var url = "/api/" + OSM.API_VERSION + "/notes.json?bbox=" + bounds.toBBoxString();
66 if (noteLoader) noteLoader.abort();
74 function success(json) {
77 json.features.forEach(updateMarkers);
79 function updateMarkers(feature) {
80 var marker = oldNotes[feature.properties.id];
81 delete oldNotes[feature.properties.id];
82 notes[feature.properties.id] = updateMarker(marker, feature);
85 for (var id in oldNotes) {
86 noteLayer.removeLayer(oldNotes[id]);