Intent For opening google maps with specific search text - android

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.

Related

intent for direct turn by turn navigation on google maps along with mode of transit

My google maps intent code, It works and I have used this because I don't want to click the start button, this intent takes me to the turn by turn navigation:
Uri gmmIntentUri =
Uri.parse("google.navigation:q=22.5850383,88.3425874");
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri); mapIntent.setPackage("com.google.android.apps.maps");
startActivity(mapIntent);
I want to specify the mode of transit as 'driving', I have tired
Uri.parse("google.navigation:q=22.5850383,88.3425874&mode=driving");
but it's not working.how do I specify transit mode as driving in the intent code
There are certain parameters you can supply via the navigation intent
Query
q: Sets the end point for navigation searches. This can be a latitude,longitude or a query formatted address. If it is a query
string that returns more than one result, the first result will be
selected.
Mode mode sets the method of transportation. Mode is optional, defaults to driving, and can be set to one of:
d for driving
w for walking
b for bicycling
Avoid avoid sets features the route should try to avoid. Avoid is optional and can be set to one or more of:
t for tolls
h for highways
f for ferries
Example
Uri gmmIntentUri = Uri.parse("google.navigation:q=22.5850383,88.3425874&mode=d");
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
mapIntent.setPackage("com.google.android.apps.maps");
startActivity(mapIntent);
I think you have to append &mode=d to the uri instead of &mode=driving
Documentation
https://developers.google.com/maps/documentation/urls/android-intents

Is it possible to intent navigation 2 more points in google maps android?

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);
It code for 2 points and what about if it will 20 points?
As I know Google Maps recommends 23 points
enter image description here
You can now use the Google Maps URLs API launched by Google in May 2017.
https://developers.google.com/maps/documentation/urls/guide
Using this API you can construct navigation URL and specify waypoints in addition to origin and destination.
So the sample code might be something like
Uri gmmIntentUri = Uri.parse("https://www.google.com/maps/dir/?api=1&origin=Madrid,Spain&destination=Barcelona,Spain&waypoints=Zaragoza,Spain%7CHuesca,Spain&travelmode=driving&dir_action=navigate");
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
mapIntent.setPackage("com.google.android.apps.maps");
startActivity(mapIntent);
I hope this helps!

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/

Android: Open Google Map (Fragment inside my app) with traffic detail

I want to display all traffic detail within my app on Map fragment
As for now I'm using google intent
Uri gmmIntentUri = Uri.parse
("geo:0,0?z=15&q=traffic+on+map");
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
mapIntent.setPackage("com.google.android.apps.maps");
startActivity(mapIntent);
For map fragment I am referring this
https://developers.google.com/maps/documentation/android/map
How do I enable traffic layer on this?
You want to display traffic layer on your Google map fragment
use your googleMap object and
googleMap.setTrafficEnabled(true);
for ref
https://developers.google.com/android/reference/com/google/android/gms/maps/GoogleMap#setTrafficEnabled(boolean)

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