Search code examples
javascriptgoogle-mapsgisopenlayers

how to get co-ordinates of vector layer line points from openlayers?


I am not able to find out how to get lat-lon values of all the points in the drawn line in the openlayer vector layer, like this openlayer-example. please help me where to search...?


Solution

  • http://dev.openlayers.org/releases/OpenLayers-2.9/doc/apidocs/files/OpenLayers-js.html

    Get layer instance(OpenLayers.Layer.Vector) from map.layers array. Iterate over features(OpenLayers.Feature.Vector) in layer.features. Access geometry(OpenLayers.Geometry) of feature using feature.geometry. This can be any type of geometry. For line the type is OpenLayers.Geometry.LineString. Use getVertices function to get array of all points(OpenLayer.Geometry.Point) in teh line.