[OpenLayers-Users] Center fo a line geometry? click event...

Marc Jansen jansen at terrestris.de
Mon Jan 18 06:51:34 EST 2010


Hi Poul,

it should be possible to position the popup at the clicked coordinate via:

// evt is the argument passed over to the trigger-function
lonlat = map.getLonLatFromViewPortPx(evt.xy);

// use the above lonlat object to position the popup:
popup = new OpenLayers.Popup.FramedCloud(
  "chicken",
  lonlat,
  new OpenLayers.Size(200,200)
// etc...
);

untested.

regards,
Marc 



paweluz wrote:
> Hi
>
> I have a problem with openlayers. I Have a roads on my map that are serve by
> WFS. I used function onFeatureSelect(feature) to get to the attributes of
> this geometry. I show them in a popup menu. The problem is shown on the
> screen below.
>
> http://zapodaj.net/1574e8d9d73c.jpg.html
>
> The blue arrow shows the place where I clicked. I want to show popup menu in
> the place when I click , not in the center of geometry. This may work with
> point geometry but not in line geometry. The click example i took from the
> openlayers example page:http://openlayers.org/dev/examples/click.html My
> popup menu looks like this:
>
>             popup = new OpenLayers.Popup.FramedCloud("chicken", 
>                                     
> feature.geometry.getBounds().getCenterLonLat(),
>                                      new OpenLayers.Size(200,200),
>                                      "<div style='font-size:.8em'>Feature: "
> + selectedFeature.attributes['shapeid'] +"<br />Area: " +
> selectedFeature.attributes['shapename']+"</div>",
>                                      null, true, onPopupClose);
>
>
> When I have both onFeatureSelect and click it does not work. Does anyone
> have an idea how to place popup menu in place where I clicked on a line
> geometry????
>
> Regards,
> Poul
>
>   


-- 


  Dipl.-Geogr. Marc Jansen
  - Anwendungsentwickler -

  terrestris GmbH & Co. KG
  Irmintrudisstraße 17
  53111 Bonn

  Tel:    ++49 (0)228 / 96 28 99 -53
  Fax:    ++49 (0)228 / 96 28 99 -57

  Email:  jansen at terrestris.de
  Web:    http://www.terrestris.de

  Amtsgericht Bonn, HRA 6835
  Komplementärin:  terrestris Verwaltungsgesellschaft mbH
  vertreten durch: Hinrich Paulsen, Till Adams  





More information about the Users mailing list