Google Maps Intent with marker & user position - android

Can you launch from an APK a Google Maps intent that includes both a marker with a specific location and the user position? I've been trying to but haven't been able as of yet.

http://wptrafficanalyzer.in/blog/storing-and-retrieving-locations-in-sqlite-from-google-maps-android-api-v2/
try this site man i guess it will help.helped me though.

You can try this:
String uri = "http://maps.google.com/maps?saddr=" + latitude +","+ longitude +"&daddr=" + userLatitude + "," + userLongitude;
startActivity(new Intent(android.content.Intent.ACTION_DEFAULT, Uri.parse(uri)));

Related

Android - How to launch Google map intent in android app setting both zoom level and marker

My question is very similar to this question (Android - How to launch Google map intent in android app with certain location, zoom level and marker) but the accepted answer is not working for me. It opens the map with the marker at the correct place and at the correct zoom level but then proceeds to zoom in to a street level view (zoom=16 or 17?).
I've search SO, I've read through this documentation but can't find a combination of place marker & zoom that do what I need.
I've tried with a few devices using Google Maps versions
8.2.0,
9.20.1,
9.36.2 &
9.42.3
Here is the result of the log print (the Uri used for the intent)
geo:39.29038619995117,-76.61219024658203?q=39.29038619995117%2C-76.61219024658203(Baltimore)&z=11
The answer from the other post is 4 years old now. Has Maps changed such that this doesn't work now? Did the other answer only work because they were setting the zoom to 17 and didn't notice it wouldn't settle on another zoom level? Am I missing something else?
To clearly state my question:
How can I use a geo intent to open a maps app to show a place marker and simultaneously choose a zoom level?
My code, based on the accepted answer from the other post.
double latitude = item.getLatitude();
double longitude = item.getLongitude();
String label = item.getName();
String uriBegin = "geo:" + latitude + "," + longitude;
String query = latitude + "," + longitude + "(" + label + ")";
String encodedQuery = Uri.encode(query);
String uriString = uriBegin + "?q=" + encodedQuery + "&z=11";
mListener.onListFragmentInteraction(uriString);
Then
public void onListFragmentInteraction(String url) {
Uri geoLocation = Uri.parse(url);
Log.d(TAG, "geo uri = " + geoLocation);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(geoLocation);
startActivity(intent);
}
#Gary99 for removing restaurant u have to add hiding map feature content here is the link(https://developers.google.com/maps/documentation/android-api/hiding-features)
Uri gmmIntentUri = Uri.parse("geo:37.7749,-122.4194?z=10&q=restaurants")
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri)
mapIntent.setPackage("com.google.android.apps.maps")
startActivity(mapIntent)

Android Sygic intent

I followed the instructions at http://dev.sygic.com/documentation/custom-url-schema/ & http://help.sygic.com/entries/22207668-Developers-Only-Sygic-implementation-to-your-app-Android-SDK-iPhone-SDK-Url-Handler-
I am passing the coordinates to Sygic 12.991030334592057 as latitude and 77.80791163444519 as longitude.
Another com.sygic.aura://coordinate|12.9138|77.6680|drive
However Sygic says 'The coordinates are outside the map.'
String str = "http://com.sygic.aura/coordinate|" + latitude + "|"
+ longitude + "|" + type.toString();
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(str)));
I also tried
String str = "com.sygic.aura://coordinate|" + latitude + "|"
+ longitude + "|" + type.toString();
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(str)));
EDIT:
The type is enum. type.toString shows drive as the string.
What am I doing wrong?
Got the same problem. As enli was saying, the order of the lat,lon params is the opposite. This code worked for me:
String str = "com.sygic.aura://coordinate|" + lon + "|" + lat + "|" + type.toString();
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(str)));
in my phone, this example call launched sygic and started navigation:
com.sygic.aura://coordinate|-3.588678|37.176278|drive
Hope it helps
There is nothing wrong with your code. Have you made sure that those values of longitude and latitude are correct? With which application you got those co-ordinates?
I was working on the same code today and it seems that I had used longitude at the place of latitude and vice versa. Try interchanging the co-ordinates. That worked for me when I was in the same boat as yours. If that is not the case, make sure that you have Sygic maps for that location by manually navigating to that location by navigating to that location from Menu > Navigate to... > GPS coordinates.

geo: Intent with label (Android)

Is there a working way (i heard that as of update 7.0 there were some changes) to display a marker with a position given by latitude/longitude with a label?
geo:?q=latitude, longitude (Label) does not work...
Show point on google map via an intent:
String uri = "geo:"+ latitude + "," + longitude;
startActivity(new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(uri)));
You can also choose to place a point like so:
String uri = "geo:"+ latitude + "," + longitude + "?q=my+street+address";
startActivity(new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(uri)));
The Possible Query params options are the following:
Show map at location: geo:latitude,longitude
Show zoomed map at location: geo:latitude,longitude?z=zoom
Show map at location with point: geo:0,0?q=my+street+address
Show map of businesses in area: geo:0,0?q=business+near+city

android Map view Issue

I have made an application containing facility of viewing current location on map. I have used default Map Intent to show map. It Works fine in Emulator but when I am testing in my Android device (motorola Millstone) , Map works fine but after view map, my application is not responding.anyone have any ideas why it happens?
String path = "http://maps.google.com/maps?saddr=" + lat + ","+ lon + "&daddr=" + b_latt + "," + b_lang;
String geoUriString = new String(path);
Uri geoUri = Uri.parse(geoUriString);
Intent mapCall = new Intent(Intent.ACTION_VIEW, geoUri);
startActivity(mapCall);
You want to show One Marker at Current Location,but In the code you shown you are passing two values to draw path..
To show user's Current Location on Map via intent you need to call this way
String uri = "geo:"+ latitude + "," + longitude;
startActivity(new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(uri)));
You can see More on This Site

How do I show a marker in Maps launched by geo URI Intent?

I have a application where I want to show different locations (one at the time, picked by user input) by launching Google Maps with their specific geo coordinates.
I'm currently using this (with real lat. and long. values of course):
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("geo:<lat>,<long>?z=17"));
startActivity(intent);
It's quite exactly what I want, except that it doesn't show any indicator or marker for the specified point. It only centers at it's location.
Is there some way to get the marker or something else included without using a MapView?
Try this:
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("geo:<lat>,<long>?q=<lat>,<long>(Label+Name)"));
startActivity(intent);
You can omit (Label+Name) if you don't want a label, and it will choose one randomly based on the nearest street or other thing it thinks relevant.
There are many more options to launch a Google map using an intent...
Double myLatitude = 44.433106;
Double myLongitude = 26.103687;
String labelLocation = "Jorgesys # Bucharest";
1)
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("geo:<" + myLatitude + ">,<" + myLongitude + ">?q=<" + myLatitude + ">,<" + myLongitude + ">(" + labelLocation + ")"));
startActivity(intent);
2)
String urlAddress = "http://maps.google.com/maps?q="+ myLatitude +"," + myLongitude +"("+ labelLocation + ")&iwloc=A&hl=es";
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(urlAddress));
startActivity(intent);
3)
String urlAddress = "http://maps.googleapis.com/maps/api/streetview?size=500x500&location=" + myLatitude + "," + myLongitude + "&fov=90&heading=235&pitch=10&sensor=false";
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(urlAddress));
startActivity(intent);
The accepted answer is correct, except when your label has an ampersand (&) in it.
Looking at A Uniform Resource Identifier for Geographic Locations ('geo' URI):
Section 5.1 states:
if the final URI is to include a 'query' component, add the
component delimiter "?" to the end of the result, followed by the
encoded query string.
Unfortunately for us, doing this will also escape the '=' which is not what we want.
We should do this:
String label = "Cinnamon & Toast";
String uriBegin = "geo:12,34";
String query = "12,34(" + label + ")";
String encodedQuery = Uri.encode(query);
String uriString = uriBegin + "?q=" + encodedQuery;
Uri uri = Uri.parse(uriString);
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, uri);
startActivity(intent);
This string works well for me:
String geoUriString="geo:"+lat+","+lon+"?q=("+head+")#"+lat+","+lon;
Uri geoUri = Uri.parse(geoUriString);
Log.e(TAG, "String: "+geoUriString);
Intent mapCall = new Intent(Intent.ACTION_VIEW, geoUri);
startActivity(mapCall);
Try appending (LocationMarkerName) to the geo: uri. For example, "geo:,?z=17(LocationMarkerName)"
In Google Maps on Android searching for 23.0980,30.6797 (NamedMarker), it seems to centre the map and position a marker with name NamedMarker at that position.
I just confirmed the following snippet from #Kenton Price still works on Android 4.4 (KitKat):
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("geo:<lat>,<long>?q=<lat>,<long>(Label+Name)"));
startActivity(intent);
I have only used Overlays with the MapView for drawing markers on top of a map. If your view is showing your map, it might be possible to simply draw your marker at the centre of the screen, in the same way as you would draw any image on a View.
However, the marker wouldn't be linked to the actual map coordinates, but if it's just a static view, then this might do.

Categories

Resources