Businesses and other points of interest

Select platform: Android iOS JavaScript

By default, points of interest (POIs) appear on the base map along with their corresponding icons. POIs include parks, schools, government buildings, and more. In addition, business POIs appear by default on the map when the map type is kGMSTypeNormal . Business POIs represent businesses such as shops, restaurants, hotels, and more.

A POI corresponds to a Place ID , as defined in the Places SDK for iOS. For example, recreational parks are POIs, but things like water fountains are generally not POIs (unless they're of national or historic significance).

Listening for click events on POIs

If you want to respond to a user tapping on a POI, implement GMSMapViewDelegate , and implement the mapView(_:didTapPOIWithPlaceID:name:location:) method, as shown in the following example:

Swift

 import 
  
 GoogleMaps 
 class 
  
 POI 
 : 
  
 UIViewController 
 , 
  
 GMSMapViewDelegate 
  
 { 
  
 override 
  
 func 
  
 loadView 
 () 
  
 { 
  
 let 
  
 camera 
  
 = 
  
 GMSCameraPosition 
 . 
 camera 
 ( 
  
 withLatitude 
 : 
  
 47.603 
 , 
  
 longitude 
 : 
 - 
 122.331 
 , 
  
 zoom 
 : 
 14 
  
 ) 
  
 let 
  
 mapView 
  
 = 
  
 GMSMapView 
 . 
 map 
 ( 
 withFrame 
 : 
  
 . 
 zero 
 , 
  
 camera 
 : 
  
 camera 
 ) 
  
 mapView 
 . 
 delegate 
  
 = 
  
 self 
  
 self 
 . 
 view 
  
 = 
  
 mapView 
  
 } 
  
 func 
  
 mapView 
 ( 
  
 _ 
  
 mapView 
 : 
  
 GMSMapView 
 , 
  
 didTapPOIWithPlaceID 
  
 placeID 
 : 
  
 String 
 , 
  
 name 
 : 
  
 String 
 , 
  
 location 
 : 
  
 CLLocationCoordinate2D 
  
 ) 
  
 { 
  
 print 
 ( 
 "You tapped 
 \( 
 name 
 ) 
 : 
 \( 
 placeID 
 ) 
 , 
 \( 
 location 
 . 
 latitude 
 ) 
 / 
 \( 
 location 
 . 
 longitude 
 ) 
 " 
 ) 
  
 } 
 } 
  

Objective-C

 #import "POI.h" 
 @import 
  
 GoogleMaps 
 ; 
 @interface 
 POI 
  
 () 
  
< GMSMapViewDelegate 
> @end 
 @implementation 
 POI 
 - 
 ( 
 void 
 ) 
 loadView 
  
 { 
  
 GMSCameraPosition 
  
 * 
 camera 
  
 = 
  
 [ 
 GMSCameraPosition 
  
 cameraWithLatitude 
 : 
 47.603 
  
 longitude 
 : 
 -122.331 
  
 zoom 
 : 
 14 
 ]; 
  
 GMSMapView 
  
 * 
 mapView 
  
 = 
  
 [ 
 GMSMapView 
  
 mapWithFrame 
 : 
 CGRectZero 
  
 camera 
 : 
 camera 
 ]; 
  
 mapView 
 . 
 delegate 
  
 = 
  
 self 
 ; 
  
 self 
 . 
 view 
  
 = 
  
 mapView 
 ; 
 } 
 #pragma mark - GMSMapViewDelegate 
 - 
 ( 
 void 
 ) 
 mapView: 
 ( 
 GMSMapView 
  
 * 
 ) 
 mapView 
  
 didTapPOIWithPlaceID 
 :( 
 NSString 
  
 * 
 ) 
 placeID 
  
 name 
 :( 
 NSString 
  
 * 
 ) 
 name 
  
 location 
 :( 
 CLLocationCoordinate2D 
 ) 
 location 
  
 { 
  
 NSLog 
 ( 
 @"You tapped %@: %@, %f/%f" 
 , 
  
 name 
 , 
  
 placeID 
 , 
  
 location 
 . 
 latitude 
 , 
  
 location 
 . 
 longitude 
 ); 
 } 
 @end 
  

Showing details in an info window

POIs appear on the map by default, but there is no default on-click UI (the API does not automatically display an info window or any other user interface when the user taps a POI). The following example shows how to use a marker to display an info window for a POI:

Swift

 // Declare GMSMarker instance at the class level. 
 let 
  
 infoMarker 
  
 = 
  
 GMSMarker 
 () 
 // Attach an info window to the POI using the GMSMarker. 
 func 
  
 mapView 
 ( 
  
 _ 
  
 mapView 
 : 
  
 GMSMapView 
 , 
  
 didTapPOIWithPlaceID 
  
 placeID 
 : 
  
 String 
 , 
  
 name 
 : 
  
 String 
 , 
  
 location 
 : 
  
 CLLocationCoordinate2D 
 ) 
  
 { 
  
 infoMarker 
 . 
 snippet 
  
 = 
  
 placeID 
  
 infoMarker 
 . 
 position 
  
 = 
  
 location 
  
 infoMarker 
 . 
 title 
  
 = 
  
 name 
  
 infoMarker 
 . 
 opacity 
  
 = 
  
 0 
 ; 
  
 infoMarker 
 . 
 infoWindowAnchor 
 . 
 y 
  
 = 
  
 1 
  
 infoMarker 
 . 
 map 
  
 = 
  
 mapView 
  
 mapView 
 . 
 selectedMarker 
  
 = 
  
 infoMarker 
 } 
  

Objective-C

 // Declare a GMSMarker instance at the class level. 
 GMSMarker 
  
 * 
 infoMarker 
 ; 
 // Attach an info window to the POI using the GMSMarker. 
 - 
 ( 
 void 
 ) 
 mapView: 
 ( 
 GMSMapView 
  
 * 
 ) 
 mapView 
  
 didTapPOIWithPlaceID 
 :( 
 NSString 
  
 * 
 ) 
 placeID 
  
 name 
 :( 
 NSString 
  
 * 
 ) 
 name 
  
 location 
 :( 
 CLLocationCoordinate2D 
 ) 
 location 
  
 { 
  
 infoMarker 
  
 = 
  
 [ 
 GMSMarker 
  
 markerWithPosition 
 : 
 location 
 ]; 
  
 infoMarker 
 . 
 snippet 
  
 = 
  
 placeID 
 ; 
  
 infoMarker 
 . 
 title 
  
 = 
  
 name 
 ; 
  
 infoMarker 
 . 
 opacity 
  
 = 
  
 0 
 ; 
  
 CGPoint 
  
 pos 
  
 = 
  
 infoMarker 
 . 
 infoWindowAnchor 
 ; 
  
 pos 
 . 
 y 
  
 = 
  
 1 
 ; 
  
 infoMarker 
 . 
 infoWindowAnchor 
  
 = 
  
 pos 
 ; 
  
 infoMarker 
 . 
 map 
  
 = 
  
 mapView 
 ; 
  
 mapView 
 . 
 selectedMarker 
  
 = 
  
 infoMarker 
 ; 
 } 
  

Stopping POIs from showing on the map

You can hide POIs by applying custom styles to all POIs or to specific categories of POIs.

The following JSON style declaration hides all business POIs on the map:

 [
  {
    "featureType": "poi.business",
    "stylers": [
      { "visibility": "off" }
    ]
  }
] 

As another example, the following JSON simplifies the display of all categories of POIs:

  [ 
  
 { 
  
 "featureType" 
 : 
  
 "poi" 
 , 
  
 "stylers" 
 : 
  
 [ 
  
 { 
  
 "visibility" 
 : 
  
 "simplified" 
  
 } 
  
 ] 
  
 } 
 ] 
 

For more details, see the guide to hiding map features with styling .

Create a Mobile Website
View Site in Mobile | Classic
Share by: