I'd like to send Intent from Google Maps to the Android app I'm developing, that would include geo information (latitude, longitude, etc).
I know it requires setting up an intent filter, however the only one I got working so far is the plain/text one:
<intent-filter>
<action android:name="android.intent.action.SEND"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="text/plain"/>
</intent-filter>
This however only gives me textual description looking like this:
899 Green St, San Francisco, CA 94133, https://goo.gl/maps/R4A82MNvUpA2
I've experimented with the below, however that didn't work (the intent wasn't even registered in Google Maps):
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
<action android:name="android.intent.action.VIEW" />
<data android:scheme="geo" />
</intent-filter>
Does anyone know how to do this? I'm using Android 9 (Pie).
Note that the Maps Embed API, Maps SDK for Android, and Maps SDK for iOS currently have no usage limits and are at no charge (usage of the API or SDKs is not applied against your $200 monthly credit).
What is the Google Maps Platform? The Google Maps Platform is a set of APIs and SDKs that allows developers to embed Google Maps into mobile apps and web pages, or to retrieve data from Google Maps.
I was having a similar problem and I found a way.
use geocoding to get location data:
https://maps.googleapis.com/maps/api/geocode/json?address=899+Green+St,+San+Francisco,+CA+94133&key=your_key
you will the lat and lng with a bunch of other data:
{
"results": [
{
"address_components": [
{
"long_name": "899",
"short_name": "899",
"types": [
"street_number"
]
},
{
"long_name": "Green Street",
"short_name": "Green St",
"types": [
"route"
]
},
{
"long_name": "Russian Hill",
"short_name": "Russian Hill",
"types": [
"neighborhood",
"political"
]
},
{
"long_name": "San Francisco",
"short_name": "SF",
"types": [
"locality",
"political"
]
},
{
"long_name": "San Francisco County",
"short_name": "San Francisco County",
"types": [
"administrative_area_level_2",
"political"
]
},
{
"long_name": "California",
"short_name": "CA",
"types": [
"administrative_area_level_1",
"political"
]
},
{
"long_name": "United States",
"short_name": "US",
"types": [
"country",
"political"
]
},
{
"long_name": "94133",
"short_name": "94133",
"types": [
"postal_code"
]
}
],
"formatted_address": "899 Green St, San Francisco, CA 94133, USA",
"geometry": {
"bounds": {
"northeast": {
"lat": 37.7989435,
"lng": -122.4128121
},
"southwest": {
"lat": 37.7982939,
"lng": -122.4138552
}
},
"location": {
"lat": 37.7988047,
"lng": -122.4131897
},
"location_type": "ROOFTOP",
"viewport": {
"northeast": {
"lat": 37.79996768029149,
"lng": -122.4119846697085
},
"southwest": {
"lat": 37.7972697197085,
"lng": -122.4146826302915
}
}
},
"place_id": "ChIJrd0tGO6AhYARxCp3djZ6Ka0",
"types": [
"premise"
]
}
],
"status": "OK"
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With