I was looking for an answer using Google and here, and the only relevant posts i have found are:
Google Maps Android V2 and Direction API
Get driving directions using Google Maps API v2
but there is no answer there. So I have already mentioned it but I will say that again. I am looking for a solution for the Google Map API v2 using FragmentActivity and a SupportMagFragment and LatLng objects and not using MapView ,MapActivtiy and GeoPoint.
In addition i don't have the Overlay object to use so i can't paint the direction on the map, is there an alternative for that?
So is there a way to do that?
Thanks in advance.
try this solution here
you can get driving or walking direction on V2
Answer: Your saying, "but there is no answer there." is not absolutely right. In this site, you can find just only a few clues about that. I think you will not get the perfect code and concrete implement KNOW-HOWs here. In fact, many developers want to make the app to display the routing or directions on Google Maps. But I think there is no solution to get directions just only with the pure Google Maps API v2.
Answer: Here are a few good sample tutorials (click here). You can find what you want.
Answer: In the Google Maps API v2, the annoying Overlay and so on are not any more required. For this, you can find the answer in my linked site above.
The Overlay is indeed something to forget.
Polylines can easily be drawn
https://developers.google.com/maps/documentation/android/lines#add_a_polyline
Just loop through yourr points after you parsed tjhe JSON response:
Your question title is much more general than your requirements, so I will answer this in a way that I think will benefit those viewing this question and hopefully meet your requirements in perhaps a different way.
If you are not showing directions in the context of a map already being a loaded fragment and something having been done to show directions over the map (which is probably similar to what the OP is doing), it's easier and I believe standard to do this with an
Intent
.This launches a map pathing activity (through a separate application - where the app launched depends on the user's compatible apps, which by default is Google Maps) that plots directions from the origin address (
String originAddress
) to the destination address (String destinationAddress
) via roadways:(Where
activity
is simply the currently activeActivity
- obtained through whatever means are appropriate in the current programming context).The following code gets an address
String
from aLatLng
object (which must then be processed for the URI queryString
as above):This request is asynchronous, but it can be made synchronous. You will need to call
toString()
on the actual parameter passed toaddress
to obtainoriginAddress
.