Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Maps Android API v2: How to make the default POI clickable and get the place detail

When using Google Maps Android or iOS API, the map will show some place icons.

I want to know:

  1. How to make the places clickable?
  2. How to get the place detail? It there a google place id?
  3. How to disable POI layer?

When using Google Maps Javascript API, there are also POI on the map. By default, you can click on them, and will show info window of the place. You can also disable the POI layer easily. However, I didn't find any relevant APIs to do that.

screenshot

like image 925
speshiou Avatar asked Oct 26 '25 10:10

speshiou


2 Answers

Google just added this feature in Google Maps Android SDK v9.6.

Now you can register GoogleMap.OnPoiClickListener to GoogleMap to handle onPoiClick(PointOfInterest poi)

like image 118
speshiou Avatar answered Oct 29 '25 00:10

speshiou


It is stated in the Google Maps object documentation that not all icons on the map are clickable. For example, transit station icons can’t be clicked. However, markers that you add to the map are clickable, and the API has a listener callback interface for various marker interactions.

Now for your problem about Place ID, the Google Places API for Android has a documentation that can help you with it.

Place IDs are available for most locations, including businesses, landmarks, parks, and intersections. These IDs are stable, meaning that once you've identified the place ID for a place, you can reuse that value when you next look up that place. You can use the same place ID across the Google Places API and a number of Google Maps APIs. For more information about Place ID, just check the documentation link above.

I also suggest you to check this tutorial to know more about how android work with Google Places.

like image 41
KENdi Avatar answered Oct 29 '25 00:10

KENdi