//= require templates/notes/show
//= require templates/notes/new
-$(document).ready(function () {
+function initializeNotes(map) {
var params = OSM.mapParams(),
- noteLayer = new L.LayerGroup(),
+ noteLayer = map.noteLayer,
notes = {},
newNote;
})
};
- layers.push({
- layer: noteLayer,
- layerCode: "N"
- });
-
- map.noteLayer = noteLayer;
-
map.on("layeradd", function (e) {
if (e.layer == noteLayer) {
loadNotes();
});
if (OSM.STATUS != 'api_offline' && OSM.STATUS != 'database_offline') {
- if (params.layers) setMapLayers(params.layers);
- if (params.notes) map.addLayer(noteLayer);
+ if (params.notes || params.layers.indexOf('N') >= 0) 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;
-
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();
});
});
-});
+}