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;
-
map.addLayer(noteLayer);
marker.openPopup();
}
icon: noteIcons[feature.properties.status],
opacity: 0.9
});
-
marker.addTo(noteLayer).bindPopup(
createPopupContent(marker, feature.properties),
popupOptions()
);
}
-
return marker;
}
function success(json) {
var oldNotes = notes;
-
notes = {};
-
json.features.forEach(updateMarkers);
function updateMarkers(feature) {
newNote.on("remove", function (e) {
$("#createnoteanchor").removeClass("disabled").addClass("geolink");
- });
-
- newNote.on("dragstart", function (e) {
+ }).on("dragstart", function (e) {
$(newNote).stopTime("removenote");
- });
-
- newNote.on("dragend", function (e) {
+ }).on("dragend", function (e) {
e.target.openPopup();
});
});
L.DomEvent
.on(link, 'click', L.DomEvent.stopPropagation)
.on(link, 'click', L.DomEvent.preventDefault)
+ .on(link, 'click', this._toggle, this)
.on(link, 'dblclick', L.DomEvent.stopPropagation);
+ this.map = map;
+
return container;
+ },
+
+ // TODO: this relies on notesLayer on the map
+ _toggle: function() {
+ if (this.map.hasLayer(this.map.noteLayer)) {
+ this.map.removeLayer(this.map.noteLayer);
+ } else {
+ this.map.addLayer(this.map.noteLayer);
+ }
}
});