从开放图层中的现有线获取坐标
我对开放图层很陌生,但在以下帮助下我成功绘制了线条和多边形: http://openlayers.org/dev/examples/draw-feature.html
我想知道如何从向量中获取经度和纬度? 我在这里看到了一个解释:如何从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});
I'm quite new to Open Layers but i have suceeded in drawing lines and polygones 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});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你好
您可以通过以下方式获取您的点的特征:
您可以使用 for 循环一一选择您的矢量特征...
但首先你想做什么?你想要选择点特征还是其他东西?
hi
you can take feauture of your point by:
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?