]> git.openstreetmap.org Git - rails.git/blobdiff - app/assets/javascripts/index/notes.js.erb
Layers work
[rails.git] / app / assets / javascripts / index / notes.js.erb
index 54e0d5df7d2e700715dbfd27d42a835c1fb64365..81d6042c707b28656caaee85d7b5804a3fe74348 100644 (file)
@@ -3,7 +3,7 @@
 
 $(document).ready(function () {
   var params = OSM.mapParams(),
-      noteLayer = new L.LayerGroup(),
+      noteLayer = new L.LayerGroup({code: 'N'}),
       notes = {},
       newNote;
 
@@ -25,11 +25,6 @@ $(document).ready(function () {
     })
   };
 
-  layers.push({
-    layer: noteLayer,
-    layerCode: "N"
-  });
-
   map.noteLayer = noteLayer;
 
   map.on("layeradd", function (e) {
@@ -57,16 +52,13 @@ $(document).ready(function () {
   });
 
   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();
         }
@@ -86,13 +78,11 @@ $(document).ready(function () {
         icon: noteIcons[feature.properties.status],
         opacity: 0.9
       });
-
       marker.addTo(noteLayer).bindPopup(
         createPopupContent(marker, feature.properties),
         popupOptions()
       );
     }
-
     return marker;
   }
 
@@ -115,9 +105,7 @@ $(document).ready(function () {
 
     function success(json) {
       var oldNotes = notes;
-
       notes = {};
-
       json.features.forEach(updateMarkers);
 
       function updateMarkers(feature) {
@@ -274,13 +262,9 @@ $(document).ready(function () {
 
     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();
     });
   });