2

我正在尝试使用 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]); 
.....

非常感谢任何帮助。

4

1 回答 1

5

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

//Insert a point in the current sketch given x & y coordinates    
draw.insertXY(cords[0], cords[1]);    
于 2011-09-17T12:15:35.897 回答