Get co-ordinates from existing line in Open Layers
I'm quite new to Open Layers but i have suceeded in drawing lines and p开发者_如何学编程olygones with help from: http://openlayers.org/dev/examples/draw-feature.html
I wonder how do i get the longitude and latitude from a vector? I saw a explanation here: how to get co-ordinates of vector layer line points from openlayers? but I'm to new to make it work.
Can anyone help me with the code or provide an example?
EDIT: Here is the solution.
function lineAdded(feature) {
var nodes = feature.geometry.getVertices();
for (var i=0; i<nodes.length; i++) {
var lon = nodes[i].x;
var lat = nodes[i].y;
console.log("lon: "+lon+", lat"+lat);
}
}
lineControl = new OpenLayers.Control.DrawFeature(vectors, path, {'featureAdded': lineAdded});
hi you can take feauture of your point by:
map.vectorLayer.features[i]
you can select one by one your vector feature with for loop ... but first of all what u want to do? yo wanna selected point feature or another thing?
精彩评论