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.
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 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 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
I know it is possible to start google maps with a route of 2 points but I really need to start it with many waypoints. How can this be done?
And another big wish would be: (I really doubt that this is possible but who knows?)
Can you somehow put those waypoints information into an intent so that it isn't necessarily for google maps but for ANY navigation app? So that the user can choose his own navigation app...?
Ok I found a way to do it with google maps:
Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("https://maps.google.ch/maps?saddr=[address1]&daddr=[address2] to:[address3] to: [address4]"));
startActivity(intent);
(Replace [address#] with the waypoints)
The problem is that the google maps app doesn't show all the waypoints but only the first and the last. I'd really like to make all waypoints visible and to make navigation actually navigate you to the points and telling you when you've reached one, but google doesn't seem to think that this is needed...
i don't wanna use a MapView an some Overlays. I only want to use the given intent Google Maps. Showing a Adress in Google Maps works fine when i call it from my application using Uri.parse("geo: ...") ... But i only see the map centered at the given adress. There are no marker or "bubble" like they are when i do a search in google maps. I can define the Zoom in the Uri with "z=12" ... Is there one thing i had to set up to see the marker and the "bubble"?!
Thank you!!!
Is there one thing i had to set up to see the marker and the "bubble"?!
There is no documented and supported means to put a "marker" or "bubble" when you use a geo: URL. Bear in mind that it might not be Google Maps that winds up responding to that URL -- the user could have installed another mapping application that they choose to handle such requests.