Pergunta

Estou tentando usar o recurso de desenho do openlayer (polígono).É possível que o usuário final desenhe um polígono.Mas quero desenhar o polígono através de java script.Estou tentando usar as funções insertXY e insertDeltaXY do openlayer, mas ocorre um erro de js "O objeto não suporta propriedade ou método 'insertXY'".

Segue meu pedaço de código.

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

Qualquer ajuda é muito apreciada.

Foi útil?

Solução

Tente usar o draw objeto para inserir pontos.De acordo com Documentação OpenLayerso OpenLayers.Control.DrawFeature expõe os métodos insertXY e insertDeltaXY.Eu não sei se o seu handler objeto tem esses métodos.

//Insert a point in the current sketch given x & y coordinates    
draw.insertXY(cords[0], cords[1]);    
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top