I have an app containing a button which should present the user with directions to a local business. I wish to supply the directions using Google Maps with the inclusion of step-by-step road directions from the user's current location.
I wish for the native Google Maps app to handle the directions, but when I tried a href of https://maps.google.com/maps?q=..., Google Maps in opening the user's web browser, rather than in their Google Maps app.
This web-based map is not providing the step-by-step directions that I desire - it only provides an overhead view from point A to point B.
I have also tried
businesname
and
businessname
These hrefs do launch the native Google Maps app, but step-by-step direction are not shown.
In summary: how can I display a Google Map view to give step-by-step directions (preferably using the native app).
What you are looking for is called an intent. It is a command that passes some informations to an other app an can launch it.
What I would do is adding a method in your code that is called when the user touches the button. This method would be something like:
//Pass the link to the itinerary you want
void launchGMaps(String link) {
//Pass the link and the instruction to show something to an Intent
Intent myIntent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(link));
//Give the name of the app to start and the activity to start in this app.
myIntent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
//Gooooooooooo !
startActivity(myIntent);
}
I hope it helped.
F
If you DO NOT have inAppBrowser plugin loaded, you can do:
window.open("http://maps.google.com/maps?saddr=some+address&daddr=another+Address");
it will open a new browser window with the directions (but not the native app)
Or you can use the previous answer frouil, but to do so you must do the following.
In your main Java file, add, before the super.loadUrl call:
appView.addJavascriptInterface(this, "YouActivityName");
Then from your javascript, you use following method:
window.YouActivityName.launchGMaps("http://maps.google.com/maps?saddr=some+address&daddr=another+Address");
If you omit the saddr part android will try to use your current location and start address
You don't need any plugin.
Just Use this for any version of phonegap but don't use href in phonegap 3x.
Use window.open();
For Navigation -
window.open("google.navigation:q=23.3728831,85.3372199&mode=d" , '_system');
For Search -
window.open("geo:0,0?q=pizza" , '_system');
Read Here - https://developers.google.com/maps/documentation/android/intents
Related
This is a simple question.
I know it's possible to request to navigate to a specific place, as shown here.
I know there are also some other APIs for Google Maps (here and here), but I don't see an option to send multiple coordinates, to see the path between them, and navigate between them.
For the Web version, there is the ability for waypoints (example here and here), but not for Android.
Is it possible to do it, via Google Maps, or another app?
Or maybe even in the Google Maps API (within the current app) ?
Since V3 Google Maps Directions API support up to 23 waypoints (excluding the origin and destination) when calculating routes:
https://maps.googleapis.com/maps/api/directions/json?origin=sydney,au&destination=perth,au&waypoints=via:-37.81223%2C144.96254%7Cvia:-34.92788%2C138.60008&key=YOUR_API_KEY
So, you can draw polyline with up to 23 points and send they coords in request.
UPDATE:
Please see this tutorial.
UPDATE 2:
Example opening navigation mode of Google Maps app for route Tel-Aviv to Jerusalem via Kiryat Malakhi, Beit+Guvrin and geopoint (31.696342, 35.011337) via Intent:
Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("https://www.google.com/maps/dir/?api=1&" +
"origin=3780+St+1,+Tel-Aviv+Yafo,+Israel&destination=Jerusalem,+Israel&travelmode=driving" +
"&waypoints=Kiryat+Malakhi,+Israel%7CBeit+Guvrin,+Israel%7C31.696342, 35.011337"));
startActivity(intent);
Result:
Parameter details here.
I have two points on google map first one is the source and second is the destination, I have the route between these points on the map.Now I want to navigate user from source to destination as Google does on Google Map Like this:-
The Google Maps Android API v2 doesn't provide any functionality for navigation. It is in contradiction with Terms of Service of Maps APIs. Have a look at section 10.4 c (iii) of ToS:
No navigation. You will not use the Service or Content for or in connection with (a) real-time navigation or route guidance; or (b) automatic or autonomous vehicle control.
https://developers.google.com/maps/terms#section_10_4
If you need navigation you should create an intent that opens the Google Maps app in navigation mode. There is a Google Maps URLs that allows to construct a universal, cross-platform URL to launch Google Maps intents from your application. You can open navigation mode of native app following this documentation:
https://developers.google.com/maps/documentation/urls/guide#directions-action
Hope this helps!
There is a way to stimulate a view like that but not embedded like uber but very close.
public void loadNavigationView(String lat,String lng){
Uri navigation = Uri.parse("google.navigation:q="+lat+","+lng+"");
Intent navigationIntent = new Intent(Intent.ACTION_VIEW, navigation);
navigationIntent.setPackage("com.google.android.apps.maps");
startActivity(navigationIntent);
}
You call the method and provide the latitude and longitude.It will launch Google map navigation.Like uber
After searching, I found something on this context. Now google providing In-app Navigation and Google Maps turn-by-turn directions support. It's paid, you can check more about this on below link.
https://cloud.google.com/maps-platform/rides-and-deliveries
Not sure if it solve your problem or not.
I would like to be able to have a Google Maps direction link which, when opened on mobile (Android), would bring up directions in Google Maps using a specified direction type (e.g. bicycle).
Using the old Google Maps URL parameters you can do,
https://www.google.com/maps/preview?saddr=[insert_from_address_here]&daddr=[insert_to_address_here]&dirflg=[insert_mode_here]
but it doesn't work on mobile.
Using the new Google Maps URL parameters you can do,
https://www.google.com/maps/dir/[customer address]/[our address]/am=t/
which does work on mobile but I don't know how to specify direction type.
From the Google Forum itself, try this on your URL if this works.
Car /data=!4m2!4m1!3e0
Bicycling /data=!4m2!4m1!3e1
Walking /data=!4m2!4m1!3e2
Public Transit /data=!4m2!4m1!3e3
Airplane /data=!4m2!4m1!3e4
For example
https://www.google.com/maps/dir/747+Howard+St,+San+Francisco,+CA/55+Music+Concourse+Dr,+San+Francisco,+CA/data=!4m2!4m1!3e3
For more information, juct check the link above and this stackexchange question.
I'm trying to make an app that displays on a map the location of events, colleagues, appointments, etc. To this momento everything is fine, but now I was thinking of making it possible for the user to click the location and select a "guide me there" option, where it would open Android maps or another "pathfinding" app to the coords of that location. This because making a such a system on my app would surpass my capabilities and take a long time.
My question: is it possible to send an intent to Android maps to set travel to coords and if possible how?
AFAIK there is not an offical way to start the navigator, but
String address = google.navigation:q=yout+address+here;
Intent implicitIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(address));
startActivity(implicitIntent);
has worked for me
Some questions about Android and Google Directions Service:
Is there a native way on Android to use the Directions Service from Google or are there any nice Wrapper Frameworks?
I would like to retrieve the time needed to get from A to B and maybe show the route in a table and/or map.
As far as I know directions can only be retrieved for "walking" and "driving". Is there a way (maybe not from google) to get this Information also for public transports or "biking" ?
I don't know exactly if this is what you want, but you could fire up an intent like this:
String url = "http://maps.google.com/maps?saddr=some+address&daddr=another+Address"
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(url));
To get biking directions add "&dirflg=b" to the url. For public transport add "dirflg=r".
This will display the route in the google Maps app. If you want to get this in your app inside a mapview, please see this code at github. You could hack into the code to add biking and public transport functionality.
Hope this helps somehow.