I'm developing rails app with google maps and car routes.
I have a start and finish points for car route - two coordinates. How can I get a full car route (array of coordinates for car through streets)? Can I do it using gmaps4rails
and geocoder
?
Something like this:
start_point = [41,2423; 45,323452]
end_point = [42,2423; 42,323452]
full_route = some_method_for_calculate_route( start_point, end_point )
#paint line on map from array of points
paint_line( full_route )
Please help, thanks kindly :)
You will want to use the Google Directions API. This will return you a JSON Object (or XML) with an array of directions including distance, coordinates, and written instructions.
If you want to do it client side, you have a plunkr here.
It is highly inspired by the google documentation here.
Basically its a way to interact with google libraries