[OpenLayers-Users] Need to set modifyFeature mode after feature
select
Stephen Woodbridge
woodbri at swoodbridge.com
Tue Mar 11 11:23:34 EDT 2008
Hi all,
I have features (polygons) that have an ftype attribute that can be
'irregular|circle|rectangle' and I need to setup handlers or the modify
mode based on allowable constraints for each ftype.
So for example:
if (feature.attributes.ftype == 'irregular')
this.mode = OpenLayers.Control.ModifyFeature.RESHAPE;
else
this.mode = OpenLayers.Control.ModifyFeature.RESIZE |
OpenLayers.Control.ModifyFeature.ROTATE |
OpenLayers.Control.ModifyFeature.DRAG;
And if looks like it is already too late to do this when
this.onModificationStart(feature)
is called. It looks like this needs to be done in
this.selectFeature(object)
which is passed to the event handlers but I can not overload this
because it is passed to the event handler in ModifyFeature.initialize.
Can anyone confirm that his is indeed the current flow?
Did I miss another way to hook into this or overload some other function?
In general I think it would be good to be able to modify the mode while
ModifyFeature is running or based on the feature (or its attributes)
that is being modified.
For example, bind a mode like rotate to the control key, then if the
ctrol key is held down while modification is in progress the
ModifyFeature would switch from its current mode to ROTATE only and when
the key is released it would go back to the previous mode it was in.
This would allow for more fine grained control over feature modifications.
I also think that part of what I'm trying to do could be abstracted to
be something like rule based modification. For example, a rule for
modifying an object that is tagged as a square vs. rectangle vs. circle
vs. irregular, etc. This could be done by handlers that enforce the
conditions or a clever definition of rules whatever that might be.
ok, better stop here, too many ideas from too many cups of coffee :)
Thanks,
-Steve W
More information about the Users
mailing list