我正在尝试使用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
公开方法 insertXY
和 insertDeltaXY
。我不知道您的 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/