[OpenLayers-Dev] snapping

Tim Schaub tschaub at opengeo.org
Fri Jan 9 13:27:07 EST 2009


Hey-

Jachym Cepicky wrote:
> Hi,
> 
> it looks great, but will there be any "beforeSnap" method, which could
> be customised by the user?
> 
> /**
>  * Method: beforeSnap
>  * Customizing the resulting coordinates
>  *
>  * Parameters:
>  * point - {<OpenLayers.Point>}
>  * snapped - {Boolean} the point was already snapped to some object
>  *
>  * Returns:
>  * {Point} - resulting point
>  */
> beforeSnap: function(point,snapped) {
>         // custom snapping, e.g. server-side correction
>         // ...
>         return point;
> },
> 

Nope.  Instead, register for the "beforesnap" event on the control. 
Return false if you want to stop snapping.  Mess with the point and 
return false if you want to do something else with it.

http://trac.openlayers.org/browser/sandbox/topp/editing/lib/OpenLayers/Control/Snapping.js#L19
(line numbers subject to change)

Tim



> Thanks
> 
> Jachym
> 
> 
> 2009/1/9 Tim Schaub <tschaub at opengeo.org>:
>> Hey-
>>
>> I done some work to create a snapping agent for vector editing [1].
>> This extends (in spirit) the work started by jachym and continued by
>> fredj [2].  The snapping agent is implemented as a single control that
>> listens for vector layer events.
>>
>> This included a number of enhancements to the geometry classes and
>> sketch handlers.  One particularly nice addition (in my opinion) is
>> geometry.distanceTo for all geometry types.  I'll tease out this change
>> and others to create specific tickets.
>>
>> If others are interested in snapping, see the wiki page for more details
>> [3].  Add any comments if there are additional bits of functionality
>> that should be considered.
>>
>> Tim
>>
>> [1] http://dev.openlayers.org/sandbox/topp/editing/examples/snapping.html
>> [2] http://trac.openlayers.org/ticket/954
>> [3] http://trac.openlayers.org/wiki/Proposal/Snapping
>>
>> --
>> Tim Schaub
>> OpenGeo - http://opengeo.org
>> Expert service straight from the developers.
>> _______________________________________________
>> Dev mailing list
>> Dev at openlayers.org
>> http://openlayers.org/mailman/listinfo/dev
>>
> 
> 
> 


-- 
Tim Schaub
OpenGeo - http://opengeo.org
Expert service straight from the developers.



More information about the Dev mailing list