]> 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 ac73e13782945089c7933f60dc71ec635459e861..3a2a153936fb438d64daa0ebf61f948874beb555 100644 (file)
@@ -1,9 +1,9 @@
 //= 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;
 
@@ -25,13 +25,6 @@ $(document).ready(function () {
     })
   };
 
-  layers.push({
-    layer: noteLayer,
-    layerCode: "N"
-  });
-
-  map.noteLayer = noteLayer;
-
   map.on("layeradd", function (e) {
     if (e.layer == noteLayer) {
       loadNotes();
@@ -57,8 +50,7 @@ $(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",
@@ -274,4 +266,4 @@ $(document).ready(function () {
       e.target.openPopup();
     });
   });
-});
+}