Android google map turn-by-turn navigation issue - android

I am implementing an app that provide navigation from current location to another. For that I have used Google turn-by-turn navigation. But some devices show different end points for the same address. I have attached screenshots of two different devices. The destination address is 5121 Rhoads Avenue, Santa barbara, CA, USA
This is the code I'm using
Uri gmmIntentUri = Uri.parse("google.navigation:q=5121 Rhoads Avenue, Santa barbara, CA, USA");
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
mapIntent.setPackage("com.google.android.apps.maps");
startActivity(mapIntent);
Device A results
Device B results

Related

Intent For opening google maps with specific search text

I'm creating a local guide app on android, and I want to set an onItemClickListener to my array that will open google maps with filled search text. For example: In shopping category, there are stores like ZARA H&M. So, I want to create an Intent that will open google maps with search text "ZARA near me" etc.
Can anyone help me with it?
Thanks in advance.
You can pass the lat, lon of the area you are interested like so:
// Search for restaurants in San Francisco
Uri gmmIntentUri = Uri.parse("geo:37.7749,-122.4194?q=restaurants");
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
mapIntent.setPackage("com.google.android.apps.maps");
startActivity(mapIntent);
Or by address like so:
Uri gmmIntentUri = Uri.parse("geo:0,0?q=1600 Amphitheatre Parkway, Mountain+View, California");
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
mapIntent.setPackage("com.google.android.apps.maps");
startActivity(mapIntent);
Taken from the Google docs.

How to launch route activity on google maps without destination

How can I launch route activity on google maps from my app without specifying the destination? I am using:
Uri gmmIntentUri = Uri.parse("google.navigation:q=<>");
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
mapIntent.setPackage("com.google.android.apps.maps");
startActivity(mapIntent);
Bad behavior :
But the "to" field in google maps has "<>" string, and if I write:
Uri gmmIntentUri = Uri.parse("google.navigation:q=");
But this not working.
The idea is:
Right behavior:
There doesn't seem to be a way for you to specifically go to a specific Activity in the official Maps app (empty destinations). If you look at the Google Maps Intent, it exposes several intents that can launch Maps to display, search, navigate and use Street View. For searching location, you are required to have coordinates or optional queries and labels.

Android Map search for an address

In my Android application I am working with Google Maps, where I want to search for a particular address for example "Apple Office". So I found the current location and need to search for "Apple Office" within five km of the current position. So my address is already marked in Google Maps. I know how to search for a location
Uri gmmIntentUri = Uri.parse("geo:37.7749,-122.4194");
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
mapIntent.setPackage("com.google.android.apps.maps");
if (mapIntent.resolveActivity(getPackageManager()) != null) {
startActivity(mapIntent);
}
This will search for San Francisco... but I need to search with text. So what change do I need for that?
You have to use 'Google Places API for Android'. https://developers.google.com/places/android-api/

How to open the shortest path of google map navigation in android?

I'm opening a google map using my android program. I did it with the following URL,
http://maps.google.com/maps? saddr=31.186371,121.489885&daddr=31.249351,121.45905&mode=driving
But this opens a view like,
I want to open the shortest path(1st one in list view) from these paths. Is there a way to do this? How may I do this?
According to the documentation, you can launch the turn by turn navigation by this intent:
google.navigation:q=a+street+address
you can use these code to launch the intent:
Uri gmmIntentUri = Uri.parse("google.navigation:q=Taronga+Zoo,+Sydney+Australia");
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
mapIntent.setPackage("com.google.android.apps.maps");
startActivity(mapIntent);
As you might able to tell, this can only give a turn-by-turn direction from current location to point A, but not point A to point B. You should consider using the web direction API and draw the polyline on your own Google Maps to gain more controls.

How do I get the coordinates(latitude and longitude) that are saved in mysql and show them in maps as markers?

How do I get the coordinates(latitude and longitude) that are saved in mysql and show them in maps as markers? I have already set up a connection and it is working. Only problem is showing them in a map, rest all procedures are fine.
If you managed to retrieve coordinate data from the database and you have all the coordinates available when your map is ready, you can use GoogleMap#addMarker.
If you don't have the coordinates, please post what you have done so far.
Edit: How to open Google Maps with specific location
If your goal is to open Google Maps with specific location, then you can use geo:latitude,longitude?z=zoom Uri for your Intent.
Example code:
// Creates an Intent that will load a map of San Francisco
Uri gmmIntentUri = Uri.parse("geo:37.7749,-122.4194");
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
mapIntent.setPackage("com.google.android.apps.maps");
startActivity(mapIntent);

Categories

Resources