[OpenLayers-Users] [Users] Popup issues

Christian López Espínola penyaskito at gmail.com
Wed Oct 18 13:33:20 EDT 2006


In each loop you are changing the var feature. Then, you create a
marker with that feature. When the event success, you are showing the
popup of the last marker, who refers to the last feature created.

Maybe you can solve it using a feature array.

Greetings.


On 10/16/06, ws0x9 <dgrubba at smeinc.com> wrote:
>
> I am having a real hard time assigning pop ups to specific markers.  I don't
> think that I totally understand how to use the popup functions.  I'm using
> ajax to query a spatial database and returning the locations.  In my loop
> for the locations I have the following code:
>
> var marker_id = locations[i].getAttribute("id");
> var geo_x = locations[i].getAttribute("geo_x").toString();
> var geo_y = locations[i].getAttribute("geo_y").toString();
>
> feature = new OpenLayers.Feature("osm_wms",new
> OpenLayers.LonLat(geo_x,geo_y));
>
> var store_marker = feature.createMarker();
>
> markers.addMarker(store_marker);
>
> store_marker.events.register("mousedown", feature,function (evt) {
>         if (popup == null) {
>                 popup = feature.createPopup();
>                 popup.setContentHTML(i);
>                 popup.setBackgroundColor("yellow");
>                 popup.setOpacity(0.7);
>                 markers.map.addPopup(popup);
>         } else {
>                 markers.map.removePopup(popup);
>                 popup.destroy();
>                 popup = null;
>         }
>         Event.stop(evt);
> }   );
>
>
> after the loop I have the remove popup function:
>
>                         /**
>                          * @param {Event} evt
>                          */
>                         function onPopupMouseDown(evt) {
>                                 markers.map.removePopup(popup);
>                                 popup.destroy();
>                                 popup = null;
>                                 Event.stop(evt);
>                         }
>
> I have looked through the class reference and the live examples but I just
> can't seem to assign the unique popup to the unique marker.
>
> Thanks for the input in advance.
> --
> View this message in context: http://www.nabble.com/Popup-issues-tf2452737.html#a6835913
> Sent from the OpenLayers Users mailing list archive at Nabble.com.
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>


-- 
Christian López Espínola


More information about the Users mailing list