draw - Openlayer在Openlayer绘制功能中添加点

标签 draw polygon openlayers points

我正在尝试使用openlayer(多边形)的绘制功能。最终用户可以绘制多边形。但我想通过java脚本绘制多边形。我尝试使用openlayer的insertXY和insertDeltaXY函数,但出现js错误“对象不支持属性或方法'insertXY'”。

下面是我的代码块。

var draw = new OpenLayers.Control.DrawFeature(
        vectorLayer, 
        OpenLayers.Handler.Polygon }
        );
map.addControl(draw);
draw.activate();

//Listen for sketch events on the layer
draw.layer.events.on({
   featureadded: that.PolygonAdded
});

//Draw polygon if provided from codebehind

//Insert a point in the current sketch given x & y coordinates    
handler.insertXY(cords[0], cords[1]); 
//Insert a point given offsets from the previously inserted point.
handler.insertDeltaXY(cords[2], cords[3]); 
handler.insertDeltaXY(cords[4], cords[5]); 
.....

非常感谢任何帮助。

最佳答案

尝试使用draw对象插入点。根据OpenLayers documentation OpenLayers.Control.DrawFeature 公开方法 insertXYinsertDeltaXY。我不知道您的 handler 对象是否有这些方法。

//Insert a point in the current sketch given x & y coordinates    
draw.insertXY(cords[0], cords[1]);    

关于draw - Openlayer在Openlayer绘制功能中添加点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7385804/

相关文章:

algorithm - 如何以编程方式找到多边形的方向?

SQL Server 2008+ : Best method for detecting if two polygons overlap?

javascript - ol-ext : map control bar is not show on the map

javascript - 如何在openlayers中的点之间添加线

c++ - 在OpenGL中绘制完全白色的纹理

javafx - 画一个半圆环-JavaFX

android - 如何让边框更平滑

delphi - 将多边形缩小为 TPoint 数组?

javascript - 打开图层点事件

gnuplot - Maxima 中的极坐标等高线图