Hi,
I have some code which creates drawing tools for a map in openlayers 2.12. The
code works, but what I don´t understand is that I can only modify the drawing
if I add the drawing-vector layer to the map with a handler in the code for
each drawing action - (point,polygon,line). If I add the drawing-layer to the
map before an action is triggered and remove the "add vector layer" handler in
each tool, I can still draw, but I can´t modify the drawings!?!
Here is the code showing a working version where the modify tool works. For
every action, the vector layer gets adds again via the handler. At the
beginning, the commented out line will allow the layer to be added to the map
before the drawing-actions starts, but I won´t be able to modify them.
Is there a better way to do this? It seems a very unlogical way to to this.
Thanks,
Rob
var vector = new OpenLayers.Layer.Vector("vector",{styleMap: styleMap2});
//map.addLayers([vector]); // this adds the layer to the map before the
tool actions are started.
action = new GeoExt.Action({
text: "Fläche",
icon:"images/edit_poly.png",
control: new OpenLayers.Control.DrawFeature(vector,
OpenLayers.Handler.Polygon,{
handlerOptions: {
layerOptions: {
styleMap: styleMap2
}
}}
),
map: map,
toggleGroup: "mapTools",
allowDepress: false,
handler: function(){
map.addLayers([vector]);
},
tooltip: "<b>Fläche zeichnen",
group: "mapTools"
});
actions["draw_poly"] = action;
toolbarItems_edit.push(action);
toolbarItems_edit.push('-',' ' );
action = new GeoExt.Action({
text: "Linie",
icon:"images/edit_line.png",
control: new OpenLayers.Control.DrawFeature(vector,
OpenLayers.Handler.Path,{
handlerOptions: {
layerOptions: {
styleMap: styleMap2
}
}}
),
map: map,
toggleGroup: "mapTools",
allowDepress: false,
handler: function(){
map.addLayers([vector]);
},
tooltip: "<b>Linie zeichnen",
group: "mapTools"
});
actions["draw_line"] = action;
toolbarItems_edit.push(action);
toolbarItems_edit.push('-',' ' );
action = new GeoExt.Action({
text: "Überarbeiten",
icon:"images/edit_modify.png",
control: new OpenLayers.Control.ModifyFeature(
vector,{}
),
map: map,
toggleGroup: "mapTools",
enableToggle: true,
tooltip: "<b>Elemente verschieben",
group: "mapTools"
});
actions["modify_features"] = action;
toolbarItems_edit.push(action);
toolbarItems_edit.push('-',' ' );
_______________________________________________
Users mailing list
Users@geoext.org
http://www.geoext.org/cgi-bin/mailman/listinfo/users