Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is It Possible To Open Google Maps By PlaceId?

I have a place id obtained from Google Places API, and the aim is opening Google Maps app via place id like similar approach of below

Uri gmmIntentUri = Uri.parse(String.format(Locale.ENGLISH,"geo:%f,%f", lat, lon));
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
mapIntent.setPackage("com.google.android.apps.maps");
if (mapIntent.resolveActivity(getPackageManager()) != null) {
    startActivity(mapIntent);
}

Is there a way for this ?

I have already latitude, longitude when user type for example "Eiffel Tower" from places API. And I'm storing those values for next usages(Say we are listing some sort of visited places from local database, and user click one of them and app navigates to Google Maps)

I have a few concerns

  1. If i use latitude-longitude to indicate a place instead of place id on Google Maps, what will happen if "Cafe XYZ" moved another street ?

  2. If i use place id each time to receive last location of "Cafe XYZ" (instead of stored values in my local database) the app easily hit request limits

So those concerns made me think a way that just sending place id Google Maps(like sending coordinates)

like image 713
blackkara Avatar asked Jan 27 '18 10:01

blackkara


People also ask

How do I open Google Maps in Swift?

Using Swift 5 and XCode 13, I was able to use Google's Universal cross-platform syntax to open Google Maps app in directions mode. The link will open the google maps app if it is installed on the phone. If maps is not installed it will open the url in the browser.

How do I get a link to open a Google map?

On your computer, open Google Maps. Go to the directions, map, or Street View image you want to share. Select Share or embed map. If you don't see this option, click Link to this map.

How to open Google Maps with a place ID?

Indeed, there is a way to open Google Maps app with a place ID. For this purpose you have to use Google Maps URLs that was launched in May 2017. Following the documentation of Google Maps URLs you can construct the following URL for "Eiffel Tower" (place ID ChIJLU7jZClu5kcR4PcOOO6p3I0)

Is it possible to search by placeid in Google Maps?

As far as I can determine, you can't search by placeId on the regular google maps, but the embed version does allow it, by prefixing the placeId with place_id: in the search. Place Ids can be found with this tool. Thanks for contributing an answer to Stack Overflow!

When will the Google Maps API stop accepting obsolete place IDs?

Notice: On March 30, 2022, all Google Maps Platform APIs will stop accepting certain obsolete place IDs . Beginning on March 30, 2022, any requests made using obsolete place IDs will be rejected, and return error code INVALID_REQUEST .

Can I use the same place ID across the Places API?

You can use the same place ID across the Places API and a number of Google Maps Platform APIs. For example, you can use the same place ID to reference a place in the Places API, the Maps JavaScript API , the Geocoding API , the Maps Embed API and the Roads API.


2 Answers

Indeed, there is a way to open Google Maps app with a place ID. For this purpose you have to use Google Maps URLs that was launched in May 2017. Following the documentation of Google Maps URLs you can construct the following URL for "Eiffel Tower" (place ID ChIJLU7jZClu5kcR4PcOOO6p3I0)

https://www.google.com/maps/search/?api=1&query=Eiffel%20Tower&query_place_id=ChIJLU7jZClu5kcR4PcOOO6p3I0

So, your code will be something like

Uri gmmIntentUri = Uri.parse("https://www.google.com/maps/search/?api=1&query=Eiffel%20Tower&query_place_id=ChIJLU7jZClu5kcR4PcOOO6p3I0");
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
mapIntent.setPackage("com.google.android.apps.maps");
if (mapIntent.resolveActivity(getPackageManager()) != null) {
    startActivity(mapIntent);
}

I hope this helps!

like image 175
xomena Avatar answered Nov 14 '22 21:11

xomena


It's probably super late but I was able to make it work with info we should have aside from the LatLog Searching for CenturyLink Field using latitude/longitude coordinates as well as the place ID results in the following map:

https://www.google.com/maps/search/?api=1&query=47.5951518,-122.3316393&query_place_id=ChIJKxjxuaNqkFQR3CK6O1HNNqY

enter image description here

like image 20
Carlos Rojas Avatar answered Nov 14 '22 23:11

Carlos Rojas