[OpenLayers-Users] How to use split events

Andreas Hocevar ahocevar at opengeo.org
Thu Oct 8 06:14:17 EDT 2009


Hi,

instead of working with the split event, use a beforesplit event handler
and check the geometry of the target feature. Return false from the
beforesplit handler if the target feature has more than 1 part (note:
before splitting!).

Regards,
Andreas.


emmexx wrote:
> I'm trying to use the split control to cut a line (LineString) with the
> conditione that the line can only be cut in 2 parts.
>
> I tried to use the split event with the following code:
>
> split: function(event) {
> 	var a = event.original;
> 	var b = event.features;
> 	if (b.length>2)
> 		//do something to stop splitting
>
> but I couldn't find a way to accomplish it. I tried all of the following
> to no avail:
> event.features=null
> this.deactivate()
> event.features=event.original
>
> Is there a simple way to do it or should I use a 2 steps strategy,
> setting a flag in the split event and restoring the original feature in
> the aftersplit event?
>
> Thank you
>
> 	maxx
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>   


-- 
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.




More information about the Users mailing list