[OpenLayers-Users] How to convert feature position to browser
coordinate ?
Andreas Hocevar
ahocevar at opengeo.org
Mon Nov 9 07:08:51 EST 2009
Altair wrote:
> hi list.
> I have feature on the vector layer, how to get feature position in browser
> coordinates(x,y) in pixel ?
>
var geom = feature.geometry;
var vertices = geom.getVertices();
var v, ll;
for(var i=0; i<vertices.length; i++) {
v = vertices[i];
ll = OpenLayers.LonLat.fromString(v.toShortString());
alert("Screen Coord: " + map.getPixelFromLonLat(ll));
}
This will give you the pixel coordinates relative to the map viewport.
Regards,
Andreas.
--
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.
More information about the Users
mailing list