Openlayer在Openlayer绘制功能中添加点

发布于 2024-12-04 09:01:45 字数 788 浏览 1 评论 0原文

我正在尝试使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

没有伤那来痛 2024-12-11 09:01:45

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

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

Try using the draw object to insert points. According to the OpenLayers documentation
the OpenLayers.Control.DrawFeature exposes the methods insertXY and insertDeltaXY. I don't know if your handler object has these methods.

//Insert a point in the current sketch given x & y coordinates    
draw.insertXY(cords[0], cords[1]);    
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文