Skip to content Skip to sidebar Skip to footer

Intent For Google Maps 7.0.0 With Location

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 exa

Solution 1:

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!

Solution 2:

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

publicstaticvoidlaunchGoogleMaps(Context context, double latitude, double longitude, String label) {
        Stringformat="geo:0,0?q=" + Double.toString(latitude) + "," + Double.toString(longitude) + "(" + label + ")";
        Uriuri= Uri.parse(format); 
        Intentintent=newIntent(Intent.ACTION_VIEW, uri);
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        context.startActivity(intent);
}

Solution 3:

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,longitudegeo:latitude,longitude?z=zoomgeo:0,0?q=my+street+addressgeo: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.

Post a Comment for "Intent For Google Maps 7.0.0 With Location"