A similar demo is still online at
http://wheresthepath.googlepages.com/cSnapToRouteDemo.html
A Generic function
/* Find point on lines nearest test point
test point pXy with properties .x and .y
lines defined by array aXys with nodes having properties .x
and .y
return is object with .x and .y properties and property i
indicating nearest segment in aXys
and property fFrom the fractional distance of the returned
point from aXy[i-1]
and property fTo the fractional distance of the returned point
from aXy[i] */
function getClosestPointOnLines (pXy,aXys) {...}
is in http://wheresthepath.googlepages.com/wheresthepath.htm
Use it like this to find the nearest GLatLng 'ptClose' to GLatLng
'pt' on the polyline represented by points 'gPointXys' (an array of
GPoint created using fromLatLngToPixel on the polyline's GLatLng
nodes)
var zoom = gMap.getZoom();
var pXy = G_NORMAL_MAP.getProjection().fromLatLngToPixel(pt, zoom);
var prox = getClosestPointOnLines(pXy,gPointXys);
var ptClose = G_NORMAL_MAP.getProjection().fromPixelToLatLng(new
GPoint(prox.x,prox.y),zoom);
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Maps API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/Google-Maps-API?hl=en
-~----------~----~----~----~------~----~------~--~---