From: Tom Hughes Date: Sat, 7 Jan 2012 17:21:08 +0000 (+0000) Subject: Deselect note features when the popup is closed X-Git-Tag: live~5104^2~121 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/c29bcca57b9a05a3ca1e55d5b3a089c7ef0b1a03 Deselect note features when the popup is closed --- diff --git a/app/views/site/index.html.erb b/app/views/site/index.html.erb index 43bafac40..7d7d5a163 100644 --- a/app/views/site/index.html.erb +++ b/app/views/site/index.html.erb @@ -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, - "

" + feature.attributes.id + "

", - null, true); + feature.popup = new OpenLayers.Popup.FramedCloud( + feature.attributes.id, location, null, + "

" + feature.attributes.id + "

", + null, true, function (e) { map.noteControl.unselect(feature) } + ); map.addPopup(feature.popup); // feature.popup.show();