2
我是很新的打開圖層,但我從畫線和polygones的幫助已經suceeded:http://openlayers.org/dev/examples/draw-feature.html從現有生產線獲取座標中打開圖層
我不知道如何獲得的經度和緯度,從矢量? 我看到一個解釋這裏:how to get co-ordinates of vector layer line points from openlayers? 但我新,使其工作。
任何人都可以幫助我的代碼或提供一個例子嗎?
編輯: 這裏是解決方案。
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});
你好,感謝您的回覆。基本上我想要做的是存儲LonLat座標供以後使用。我通過添加一個回調來成功。 'code'function lineAdded(feature){ var nodes = feature.geometry.getVertices(); 爲(VAR I = 0; I
2011-04-19 10:47:20
看起來好像你在這個循環則座標?那你在哪裏遇到麻煩? – 2011-04-19 11:29:45
實際上,代碼解決了它!所以沒有更多的麻煩。我只是想我可以更好地格式化代碼,以便其他人可以使用它,因爲我之前看到過這個問題,但沒有真正簡單的解決方案。 – 2011-04-19 11:47:36