I'd like to create a map displaying a feature ready to modify. The map should already be selected and show the draggable vertices when you load the page (without needing to click on the feature first).
With this code, you first need to click the feature before you can edit:
layer = new OpenLayers.Layer.WMS( "OpenLayers WMS", "http://vmap0.tiles.osgeo.org/wms/vmap0", {layers: 'basic'} );
vectorLayer = new OpenLayers.Layer.Vector("Foo");
map = new OpenLayers.Map('map');
var wkt = "POLYGON((0 1, -1 0, 1 0))";
var polygonFeature = new OpenLayers.Format.WKT().read(wkt);
vectorLayer.addFeatures([polygonFeature]);
map.addLayers([layer, vectorLayer]);
map.zoomToExtent(vectorLayer.getDataExtent());
modifyControl = new OpenLayers.Control.ModifyFeature(vectorLayer);
map.addControls([modifyControl]);
modifyControl.activate();
I already tried OpenLayers.Control.SelectFeature. It selects the feature (blue line) but it doesn't show the draggable vertices:
selectFeature = new OpenLayers.Control.SelectFeature(vectorLayer);
selectFeature.select(vectorLayer.features[0]);
selectFeature.activate();
Any ideas? Thanks!