Openlayer在Openlayer绘制功能中添加点
我正在尝试使用 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]);
.....
非常感谢任何帮助。
I am trying to use draw feature of openlayer (polygon). It is possible for the end user to draw a polygon. But I want to draw the polygon through java script. I am trying to use insertXY and insertDeltaXY functions of openlayer, but there comes a js error "Object doesn't support property or method 'insertXY'".
Follow is my chunk of code.
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]);
.....
Any help is highly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试使用
draw
对象插入点。根据 OpenLayers 文档OpenLayers.Control.DrawFeature
公开方法insertXY
和insertDeltaXY
。我不知道你的handler
对象是否有这些方法。Try using the
draw
object to insert points. According to the OpenLayers documentationthe
OpenLayers.Control.DrawFeature
exposes the methodsinsertXY
andinsertDeltaXY
. I don't know if yourhandler
object has these methods.