Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Obtaining Coordinates from "Share this place" in Google Maps

Tags:

android

When viewing the details of any location in Google Maps, there's an option for "Share this place". I have successfully added myself to the list of receivers by adding this intent-filter to my application in the manifest:

<intent-filter>
    <action android:name="android.intent.action.SEND" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:mimeType="text/plain" />
</intent-filter>

The extras passed along with this bundle are Intent.EXTRA_SUBJECT and Intent.EXTRA_TEXT. I retrieved these extras in my activity using:

Bundle extras = getIntent().getExtras();

Intent.EXTRA_SUBJECT contains a string with the title of the location. Intent.EXTRA_TEXT contains a string with a detailed address of the location and a mobile maps URL.

Is it at all possible to retrieve the GPS co-ordinates (latitude and longitude) of the location from the "Share this place" action?

like image 747
mattprecious Avatar asked Nov 04 '22 13:11

mattprecious


1 Answers

You can use geocoder to obtain the location from the address:

How can I find the latitude and longitude from address?

like image 56
artkoenig Avatar answered Nov 15 '22 06:11

artkoenig