]> git.openstreetmap.org Git - rails.git/blobdiff - app/assets/javascripts/index/note.js.erb
Add halo to currently selected note
[rails.git] / app / assets / javascripts / index / note.js.erb
index 4a9f432ad8956046aea22b0f14645fe11caf9abb..b6b464f73c631e9904b6b0a76ef96e7a44cf5f37 100644 (file)
@@ -2,7 +2,8 @@ OSM.Note = function (map) {
   var noteLayer = map.noteLayer,
     content = $('#sidebar_content'),
     page = {},
-    marker;
+    noteState = map.hasLayer(noteLayer),
+    halo;
 
   var noteIcons = {
     "new": L.icon({
@@ -78,13 +79,23 @@ OSM.Note = function (map) {
       clearTimeout(loadTimer);
       clearLoading();
 
-      if (!map.hasLayer(noteLayer)) map.addLayer(noteLayer);
-      if (window.location.hash == "") map.panTo($('.details').data().coordinates.split(','));
-    });
+      var data = $('.details').data();
+      if (!noteState) map.addLayer(noteLayer);
+      if (window.location.hash == "") map.panTo(data.coordinates.split(','));
+
+      if (!map.hasLayer(halo)) {
+          halo = L.circleMarker(data.coordinates.split(','), {
+            weight: 2.5,
+            radius: 20
+          });
+        map.addLayer(halo);
+      }
+  });
   };
 
   page.unload = function () {
-    if (marker) map.removeLayer(marker);
+    if (map.hasLayer(halo)) map.removeLayer(halo);
+    if (!noteState) map.removeLayer(noteLayer);
   };
 
   function setLoading() {