2

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);
}
Community
  • 1
  • 1
Gary99
  • 1,750
  • 1
  • 19
  • 33
  • 1
    This functionality was broken after Google Maps 7.x. – Harjot Singh Oberai Dec 13 '16 at 22:19
  • Refer this : https://developer.android.com/guide/components/intents-common.html#Maps – Harjot Singh Oberai Dec 13 '16 at 22:21
  • @HarjotSinghOberai "broken after 7.x". Thanks, I was afraid of that. Do you know if this was intentional or is there any chance of this being fixed? Do you know of any documentation that would cover this change? – Gary99 Dec 14 '16 at 16:24
  • you may still use the functionality, just the syntax is different, see the link that I added. – Harjot Singh Oberai Dec 14 '16 at 16:33
  • I've looked at this document before. It gives examples of zoom and a place marker but not using them both together. Are you seeing something I'm missing? – Gary99 Dec 14 '16 at 16:58
  • Yes, they haven't given an example of that. Try this : `String uriString = "geo:0,0?q=" + encodedQuery + "?z=11";` – Harjot Singh Oberai Dec 14 '16 at 17:08
  • I appreciate your attempts but this is not what I need either. I actually had tried this before (I also tried it again just now) but didn't mention it because it doesn't work as well as the Uri in my question. This doesn't start at the correct zoom, it just goes straight to a street level zoom. – Gary99 Dec 14 '16 at 18:16

2 Answers2

1

@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)

ripan
  • 78
  • 8
  • Thanks for the link but if I understand this, it requires me using the Google Maps API. That adds a layer of complexity I'm not willing to get into right now. I'm trying to do this with only a 'geo' intent which seems that it was possible at some time but not now. – Gary99 Dec 15 '16 at 17:51
0
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)

ripan
  • 78
  • 8
  • I passed over this when I saw it in the documentation. I just tried it to make sure but I'm not really interested in restaurants. Thanks for the attempt but this is not really what I'm looking for. – Gary99 Dec 14 '16 at 02:24
  • @Gary99 for removing restaurant u have to add hiding map feature content here is the link: – ripan Dec 15 '16 at 17:12