Hi Rob,

This would indeed be a nice feature to have. Looking at the ModifyFeature control, I think this could be easily accomplished with minor modifications.

If we look at the ModifyFeature control, it creates a DragFeature control to allow dragging the vertices around. When you "mouse hover" a vertex feature, a callback function is triggered because it was defined here :
https://github.com/openlayers/openlayers/blob/master/lib/OpenLayers/Control/ModifyFeature.js#L267

That's the callbacks for the OpenLayers.Handler.Feature object the drag control needs to interact with features on the map. The drag control defines its callbacks method in the featureCallbacks object :
https://github.com/openlayers/openlayers/blob/master/lib/OpenLayers/Control/DragFeature.js#L119

and here's the list of callbacks you can set to a feature handler: click, clickout, over, out, and dblclick.
https://github.com/openlayers/openlayers/blob/master/lib/OpenLayers/Handler/Feature.js#L30

So, back in the ModifyFeature control, you could add a 'click' callback function just next to the 'over' one. Instead of coding what you want it to do directly in the source, just define an abstract function that needs to be overriden OR you could fire an new vector layer event : vertexselected (which would need to be added to OpenLayer.Layer.Vector).

Whoa, sorry for the long reply :) In short, try to create a delegate method or event we could register to to do whatever we wanted on vertex selection.

  Does that make sense ?

HTH,

Alexandre


On 13-02-26 11:42 AM, Robert Smart wrote:
Hi All,

I'm trying to port some existing functionality into open layers and have
managed to get most of it working. I'm just stuck on a seemingly simple
task.

The current code allows a user to highlight a polygon vertex by clicking on
it (which changes its colour), so that the user can then press a delete
button to remove the vertex.

Using the modify control I'm able to display the vertices, and even delete them if I click on it and then press 'del' on my keyboard, but this is not a
great solution as there is no visual clue as to what vertex has been
selected.

So is there a way to highlight or change the colour of a single vertex the user has clicked on? is there then a way to remove that vertex via code and
have the polygon redraw on the screen to suit?

I think this would actually be quite useful as a standard feature as there
are many cases where one might want to select an individual vertex.

Thanks,

Rob


_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users


--
Alexandre Dubé
Mapgears
www.mapgears.com

_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users

Reply via email to