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

adidas xkadidas at gmail.com
Tue Jul 3 08:35:05 PDT 2012


03.07.2012 17:58, "Álvaro Monares G." пишет:
>> 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.
>
Thanks!!! Working it:
var lonlat = 
map.getLonLatFromPixel(map.getControlsByClass("OpenLayers.Control.MousePosition")[0].lastXy);
for LineString.


More information about the Users mailing list