i currently working with roads API and try to use lat long from my database for the path. but the polylines just draw a straight line between the points and is not following the road
function runSnapToRoad() {
var pathValues = [];
@foreach($transaction as $transac)
pathValues.push("{{$transac->latitude}},{{$transac->longitude}}");
@endforeach
$.get('https://roads.googleapis.com/v1/snapToRoads', {
interpolate: true,
key: apiKey,
path: pathValues.join('|')
}, function(data) {
processSnapToRoadResponse(data);
drawSnappedPolyline();
});
}
the pathValues[] returns perfectly the points but the polylines where just straight between the points. how can i obtain snapped polylines(lines drawn based on the roads.)
i just found out that the points(lat,lng) requested should not have a long distance between them. snapped roads is obtained when points are tight.