This class is used to snap a marker to closest point on a line, based on the current position of the cursor.

For a description and examples of how to use this library, check out the how-to.

class SnapToRoute


Constructor Description
SnapToRoute(map:GMap2, marker:GMarker, polyline:GPolyline) Creates a new SnapToRoute that will snap the marker to the route.


Methods Return Value Description
getClosestLatLng(latlng:GLatLng) GLatLng Calculate closest lat/lng on the polyline to a test lat/lng.
getDistAlongRoute(latlng?:GLatLng) Number Get the distance (in meters) along the polyline of the closest point on route to test lat/lng.
updateTargets(marker:GMarker, polyline:GPolyline) None Change the marker and/or polyline used by the class.