[OpenLayers-Users] Show pop-up where user clicked

"Álvaro Monares G." amonares at dcc.uchile.cl
Tue Jul 3 07:58:04 PDT 2012


> How to change this example (
> http://openlayers.org/dev/examples/select-feature-openpopup.html  ) so
>that when the user clicks on a line (feature) pop-up display where the
> user clicked? A few days trying to do it, does not work.

The form I solve it is adding the MousePosition Control:
new OpenLayers.Control.MousePosition();
on map controls.

Then I register the layer with the line for featureselected event
and in the featureselected function I use:

var lonlat = map.getLonLatFromPixel(map.getControlsByClass("OpenLayers.Control.MousePosition")[0].lastXy);

If the feature that dispatch the event is an Linestring
feature.geometry['CLASS_NAME']=="OpenLayers.Geometry.LineString"
I show the popup in the latlon variable.


Best regards from Chile
Álvaro Monares G.



More information about the Users mailing list