Search code examples
javascriptgoogle-mapsgoogle-maps-api-3google-polyline

Google Maps get LatLng on polyline


I'm trying to get a marker (LatLon object) for a specific distance on top of a polyline on a Google Map.

Using the GetPointAtDistance function of epolys.js, I'm getting a point on the map that seems correct, but it is a little "off" the Polyline that the map generated.

Here is an example I put together to demonstrate my issue: http://jsfiddle.net/S7VPz/2/

Preferably, I would also like to use a geodesic polyline instead of a straight one.


Solution

  • For this particular polyline(geodesic line between 2 points) google.maps.geometry.spherical.interpolate() seems to be perfect : http://jsfiddle.net/doktormolle/2nAgr/