13

At first I know that there are several similar questions on StackOverflow. Curriently I use the geo scheme for addressing points which can be handled by other apps.

Like in the example of the Android documentation (by the way it seems to be outdated the RFC it out!) I tried to use something like this:

geo:50.95144,6.98725?q=50.95144,6.98725%20(Disneyland)

So I get a intent chooser where I can select an App which showed me in case of Google Maps Disneyland with a marker on it. Now it seems that an update was installed which removes that support. I just get the message that this place cannot been found.

I tried to understand the RFC 5870 which defines the 'geo' URI Scheme. I don't get it exactly. It is correct that it is not possible at all to define a lable?

How can I link now a position to Google Maps?

Community
  • 1
  • 1
rekire
  • 47,260
  • 30
  • 167
  • 264
  • By the way I'm talking about Google Maps 7.0.0 (#700002512) and I have no idea why this is only on a Nexus 7. – rekire Jul 11 '13 at 09:51
  • It's the same on my N4 with the new maps app. They removed searching for an exact geo location. You just get the next address google knows. :( – flx Jul 13 '13 at 08:43
  • It's getting even better: the webapp now knows queries like 'Disneyland@50.95144,6.98725). And the Android app can create these queries when sharing a Marker in the wild. But it can not parse these queries itself.. :( – flx Jul 25 '13 at 09:28
  • How to Link? This does not work: http://maps.Google.com/maps?q=Disneyland@50.95144,6.98725 – rekire Jul 25 '13 at 14:55
  • Same here with 7.0.2 (on Sony Experia T) – The Nail Jul 27 '13 at 20:05
  • 1
    @TheNail This seems to replated with all Maps versions 7.0.x I checked it also on the S3, S4 and HTC one. – rekire Jul 29 '13 at 07:31
  • Looks like latest Maps release fixed this problem. Intents we were used to before are working again. – flx Sep 13 '13 at 06:56
  • 2
    `adb shell am start -a android.intent.action.VIEW -n com.google.android.apps.maps/com.google.android.maps.MapsActivity -d "geo:6.88,79.91?q=6.88,79.91 (foo)"` is working for me. Maps 7.2.0 updated today. – flx Sep 13 '13 at 08:47

3 Answers3

13

The WhatsApp intent is:

START u0 {act=android.intent.action.VIEW cat=[android.intent.category.BROWSABLE] dat=https://maps.google.com/maps?q=loc:lat,lng+(You)&rlz=1Y1TXLS_enDE543DE543 flg=0x3000000 cmp=com.android.browser/.BrowserActivity (has extras)} from pid 2115

So if you use the following intent URI:

String geoUri = "http://maps.google.com/maps?q=loc:" + lat + "," + lng + " (" + mTitle + ")";

...it should behave like WhatsApp. Furthermore it seems that some other geo apps trigger on this intent too. But it doesn't work for all geo apps!

Simas
  • 43,548
  • 10
  • 88
  • 116
cradle
  • 146
  • 4
  • 2
    Sorry for the late answer...there was a bug with the decimal mark. This trick did only work for locales with a dot as decimal separator. With locales using comma as decimal separator, the dot was replaced by a comma which results in an invalid URL. But this bug was fixed with v7.2 so it should work now with every locale. – cradle Dec 07 '13 at 11:42
3

This is working on the latest Google Maps v7.1 tested on my Nexus 4.

    public static void launchGoogleMaps(Context context, double latitude, double longitude, String label) {
        String format = "geo:0,0?q=" + Double.toString(latitude) + "," + Double.toString(longitude) + "(" + label + ")";
        Uri uri = Uri.parse(format); 
        Intent intent = new Intent(Intent.ACTION_VIEW, uri);
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        context.startActivity(intent);
}
Meanman
  • 1,474
  • 20
  • 17
  • It seems that you are right they fixed that bug. Strange is only that I use Maps 7.2 and the least time it did not work. – rekire Sep 20 '13 at 11:24
1

Like in the example of the Android documentation (by the way it seems to be outdated the RFC it out!) I tried to use something like this

The four sample constructions in the documentation are:

geo:latitude,longitude
geo:latitude,longitude?z=zoom
geo:0,0?q=my+street+address
geo:0,0?q=business+near+city

You will notice that none of those have a "label" in parentheses, separated by a space from the rest of the Uri.

Now it seems that an update was installed which removes that support

That "support", if it existed before, was undocumented, and you should not have been relying upon it. You will also note that there are many mapping applications for Android, any of which the user could choose for a geo: Intent -- did you test all of these to see if your undocumented capability worked on all of them?

It is correct that it is not possible at all to define a lable?

I do not see any evidence of your label-in-parentheses syntax in that RFC. Though, I agree, these IETF RFC tend to be difficult to read.

How can I link now a position to Google Maps?

Drop the label-in-parentheses:

geo:50.95144,6.98725?q=50.95144,6.98725

And, since you don't need the ? part anymore, you could use:

geo:50.95144,6.98725

If your real question is "how can I link now a position to Google Maps and have it show my own label", probably you can't.

You are welcome to embed a mapping engine into your app (e.g., Google's Maps V2 for Android), in which case you can mark up the map to the limits of that engine's API for it. I would expect any serious mapping engine to support adding markers with some sort of label.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • AFIK WhatsApp uses too some intent which directly opens Google Maps with an pointer and a lable. I can imagine how to force opening Google Maps, but I don't know how I can force that lable. I would prefer some syntax which allows e.g. a navigation software to navigate to this point. – rekire Jul 11 '13 at 12:40
  • @rekire: "WhatsApp uses too some intent which directly opens Google Maps with an pointer and a lable" -- if true, the WhatsApp developers hate their users, as not all users will want to use Google Maps, even if Google Maps is installed on the device. No sensible developer should "force opening Google Maps". – CommonsWare Jul 11 '13 at 12:47
  • I fully agree with you. I don't want to bind my app to Google Maps. I just want to know how they enforce that the lables work. – rekire Jul 11 '13 at 13:35
  • @rekire: I am assuming that WhatsApp's behavior has not changed on your Nexus 7, indicating that they are doing something different than what you were doing. Since WhatsApp is a big brand, they probably have some direct contact with Google. It is conceivable that Google told them about some undocumented stuff for this label that is allowing them to continue using it, even though the trick you were using may now be broken. WhatsApp would still be running a risk, as there's no assurances that Google will keep maintaining whatever hook that WhatsApp is using. – CommonsWare Jul 11 '13 at 13:43
  • @rekire you can sniff intents with tools like this: https://play.google.com/store/apps/details?id=uk.co.ashtonbrsc.android.intentintercept – Marcin Orlowski Jul 31 '13 at 18:29