[OpenLayers-Users] Openlayer how to enable dragging of feature
after placing it?
Marco Pas
marco.pasopas at gmail.com
Wed Apr 6 14:57:29 EDT 2011
Hi there, it seems that i have a simple requirement but my knowledge
on OpenLayer seems to limited.
I have a need to place 1 feature inside a map and after placing it,
drag this feature to the right place and then get the Lat / Long
coordinates. It would be nice that i can delete the feature to start
over..
But to start with:
I have managed to place a feature, but am not able to switch from
drawfeature to dragfeature.
If there a better ways to achieve my goal i am more then happy to learn!
// create the map variable
map = new OpenLayers.Map("map");
// create layers
var mapLayer = new OpenLayers.Layer.OSM(); // openstreetmap
var vectorLayer = new OpenLayers.Layer.Vector("Vector", {styleMap:
styleMap}); // vector
// add the layers to the map
map.addLayer(mapLayer);
map.addLayer(vectorLayer);
map.addControl(new OpenLayers.Control.MousePosition());
var drawFeature = new OpenLayers.Control.DrawFeature(vectorLayer,
OpenLayers.Handler.Point);
var dragFeature = new OpenLayers.Control.DragFeature(vectorLayer);
map.addControl(drawFeature);
drawFeature.activate();
vectorLayer.onFeatureInsert = function () {
drawFeature.deactivate();
// how to switch to drag feature???
// dragFeature.activate(); does not seem to work
}
...
map.setCenter (lonLat, zoom);
Thanks
Marco
More information about the Users
mailing list