开发者

Openlayer adding points in Openlayer draw feature

开发者 https://www.devze.com 2023-04-04 10:06 出处:网络
I am trying to use draw feature of openlayer (polygon). It is possible for the end user to draw a polygon. But I w开发者_运维问答ant to draw the polygon through java script. I am trying to use insertX

I am trying to use draw feature of openlayer (polygon). It is possible for the end user to draw a polygon. But I w开发者_运维问答ant 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.


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]);    
0

精彩评论

暂无评论...
验证码 换一张
取 消