My app needs to show Google Maps directions from A to B, but I don't want to put the Google Maps into my application - instead, I want to launch it using an Intent. Is this possible? If yes, how?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How can I create this custom Bottom Navigation on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
Open Google Maps using Intent with different Modes:
We can open Google Maps app using intent:
Here, "mode=b" is for bicycle.
We can set driving, walking, and bicycling mode by using:
You can find more about intent with google maps here.
Note: If there is no route for the bicycle/car/walk then it will show you "Can't find the way there"
You can check my original answer here.
You could use something like this:
To start the navigation from the current location, remove the
saddr
parameter and value.You can use an actual street address instead of latitude and longitude. However this will give the user a dialog to choose between opening it via browser or Google Maps.
This will fire up Google Maps in navigation mode directly:
UPDATE
In May 2017 Google launched the new API for universal, cross-platform Google Maps URLs:
https://developers.google.com/maps/documentation/urls/guide
You can use Intents with the new API as well.
Using the latest cross-platform Google Maps URLs: Even if google maps app is missing it will open in browser
Example https://www.google.com/maps/dir/?api=1&origin=81.23444,67.0000&destination=80.252059,13.060604
This is what worked for me:
For multiple way points, following can be used as well.
First set of coordinates are your starting location. All of the next are way points, plotted route goes through.
Just keep adding way points by concating "/latitude,longitude" at the end. There is apparently a limit of 23 way points according to google docs. Not sure if that applies to Android too.
If you interested in showing the Latitude and Longitude from the current direction , you can use this :
The following query will help you perform that . You can pass the destination latitude and longitude here:
Use above as:
Or if you want to show via location , use:
More Info here: Google Maps Intents for Android