open google maps through intent for specific location in android
I have not tested this but you could try :
First method:
String uri = String.format(Locale.ENGLISH, "geo:%f,%f", latitude, longitude);
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
context.startActivity(intent);
EDIT:
This might not work with Google maps 7,0
hence you could change the uri to :
Second option:
String geoUri = "http://maps.google.com/maps?q=loc:" + lat + "," + lng + " (" + mTitle + ")";
where mTitle
is the name of the location.
Third option:
geo:0,0?q=my+street+address
Fourth option:
String map = "http://maps.google.co.in/maps?q=" + yourAddress;
Hope that works and helps :D..
How to open standard Google Map application from my application?
You should create an Intent
object with a geo-URI:
String uri = String.format(Locale.ENGLISH, "geo:%f,%f", latitude, longitude);
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
context.startActivity(intent);
If you want to specify an address, you should use another form of geo-URI: geo:0,0?q=address
.
reference : https://developer.android.com/guide/components/intents-common.html#Maps
How to Open and Directing Google Maps using Intent?
String strUri = "http://maps.google.com/maps?q=loc:" + latitude + "," + longitude + " (" + yourLocationName + ")";
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(strUri));
intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
startActivity(intent);
Open map to show direction from current location through intent-Android
To navigate user to destination lat long, we can use something like this
Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("http://maps.google.com/maps?daddr=28.605989,77.372970"));
startActivity(intent);
Here . we are passing just destination lat long daddr=28.605989,77.372970
, so by default, your current location will be source location.
To add extra information with your url .
String my_data= String.format(Locale.ENGLISH, "http://maps.google.com/maps?daddr=20.5666,45.345(My Destination Place)");
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(my_data));
intent.setPackage("com.google.android.apps.maps");
startActivity(intent);
How to Launch Google Map Intent with My Current Location
you have to try like this
String uri = String.format(Locale.ENGLISH, "geo:%f,%f", latitude, longitude);
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
context.startActivity(intent);
for more information visit here : https://developer.android.com/guide/components/intents-common.html#Maps
if you need with direction follow this
Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("http://maps.google.com/maps?saddr=20.344,34.34&daddr=20.5666,45.345"));
startActivity(intent);
Hope it will help you :)
Android - How to launch Google map intent in android app with certain location, zoom level and marker
Try the following solution:
double latitude = 40.714728;
double longitude = -73.998672;
String label = "ABC Label";
String uriBegin = "geo:" + latitude + "," + longitude;
String query = latitude + "," + longitude + "(" + label + ")";
String encodedQuery = Uri.encode(query);
String uriString = uriBegin + "?q=" + encodedQuery + "&z=16";
Uri uri = Uri.parse(uriString);
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, uri);
startActivity(intent);
Credit goes here: Answer
I believe the problem had to do with the spaces in your label. Encoding the query string will eliminate the issue by replacing the spaces with valid characters
Launching Google Maps Directions via an intent on Android
You could use something like this:
Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("http://maps.google.com/maps?saddr=20.344,34.34&daddr=20.5666,45.345"));
startActivity(intent);
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:
Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("google.navigation:q=an+address+city"));
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.
Start google map direction intent with mode
Put navigation mode as dirflg.
d
for driving.b
for bicycle.w
for walking.l
for two wheeler.val uri = Uri.parse("http://maps.google.com/maps?saddr=33.489954,73.098888 &daddr=33.499009,73.101076 &dirflg=w")
val intent = Intent(Intent.ACTION_VIEW, uri)
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
startActivity(intent)
Android: open Map intent with directions with two points
have you tried this
String uri = "http://maps.google.com/maps?f=d&hl=en&saddr="+latitude1+","+longitude1+"&daddr="+latitude2+","+longitude2;
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(uri));
startActivity(Intent.createChooser(intent, "Select an application"));
Related Topics
Android: Create a Toggle Button with Image and No Text
How to Replace a Fragment on Button Click of That Fragment
Android Listview Child View Setenabled() and Setclickable() Do Nothing
Fragment View in Viewpager Is Not Restored When Resuming
What Is The Easiest Way to Use Svg Images in Android
Android: I Want Use My Custom Font with Webviewb
Using Katzer Local Notification in Ibm Worklight
Fragmentpageradapter Getitem Is Not Called
Modifying The Color of an Android Drawable
What's "Requestcode" Used for on Pendingintent
Splash Screen While Loading a Url in a Webview in Android App
Mat (Eclipse Memory Analyzer) - How to View Bitmaps from Memory Dump
Android Studio - Error:Program Type Already Present
How to Embed a Youtube Clip in a Webview on Android
Android App Installation Failed: Package Com.My.App Has No Certificates at Entry Androidmanifest.Xml
Get Color Value Programmatically When It's a Reference (Theme)