]> git.openstreetmap.org Git - rails.git/commitdiff
Deselect note features when the popup is closed
authorTom Hughes <tom@compton.nu>
Sat, 7 Jan 2012 17:21:08 +0000 (17:21 +0000)
committerTom Hughes <tom@compton.nu>
Sat, 7 Jan 2012 17:21:30 +0000 (17:21 +0000)
app/views/site/index.html.erb

index 43bafac40f09ee652be0fdf1aacad91e8e9dc560..7d7d5a16372af3ef9f042075ce2536ae880e19d2 100644 (file)
@@ -190,10 +190,10 @@ end
       map.noteLayer.events.register("featureunselected", map, noteUnselected);
       map.addLayer(map.noteLayer);
 
-      var noteControl = new OpenLayers.Control.SelectFeature(map.noteLayer, {
+      map.noteControl = new OpenLayers.Control.SelectFeature(map.noteLayer, {
           autoActivate: true
       });
-      map.addControl(noteControl);
+      map.addControl(map.noteControl);
 
       <% if params[:notes] == "yes" -%>
       map.noteLayer.setVisibility(true);
@@ -339,10 +339,11 @@ end
     var feature = o.feature;
     var location = feature.geometry.getBounds().getCenterLonLat();
 
-    feature.popup = new OpenLayers.Popup.FramedCloud(feature.attributes.id,
-                                                     location, null,
-                                                     "<p>" + feature.attributes.id + "</p>",
-                                                     null, true);
+    feature.popup = new OpenLayers.Popup.FramedCloud(
+      feature.attributes.id, location, null,
+      "<p>" + feature.attributes.id + "</p>",
+      null, true, function (e) { map.noteControl.unselect(feature) }
+    );
 
     map.addPopup(feature.popup);
 //    feature.popup.show();