Click the map two or more times to create polylines. The marker wil snap to the polyline at all times.
/**
* Snap marker to closest point on a line.
*
* Based on Distance to line example by
* Marcelo, maps.forum.nu - http://maps.forum.nu/gm_mouse_dist_to_line.html
* Then
* @ work of Björn Brala - Swis BV who wrapped the algorithm in a class operating on GMap Objects
* And now
* Bill Chadwick who factored the basic algorithm out of the class (removing much intermediate storage of results)
* and added distance along line to nearest point calculation
*
*
* Usage:
*
* Create the class
* var oSnap = new cSnapToRoute();
*
* Initialize the subjects
* oSnap.init(oMap, oMarker, oPolyline);
*
* If needed change the marker or polyline subjects. use null when no update
* Change Both:
* oSnap.updateTargets(oMarker, oPolyline);
* Change marker:
* oSnap.updateTargets(oMarker, null);
* Change polyline:
* oSnap.updateTargets(null, oPolyline);
**/
Click the map two or more times to create polylines. The marker wil snap to the polyline at all times.