Theo mặc định, các địa điểm yêu thích (POI) sẽ xuất hiện trên bản đồ cơ sở cùng với các biểu tượng tương ứng. POI bao gồm công viên, trường học, toà nhà chính phủ và nhiều địa điểm khác. Ngoài ra, các địa điểm yêu thích doanh nghiệp sẽ xuất hiện theo mặc định trên bản đồ khi loại bản đồ là kGMSTypeNormal. POI doanh nghiệp đại diện cho các doanh nghiệp như cửa hàng, nhà hàng, khách sạn và nhiều doanh nghiệp khác.
POI tương ứng với một Mã địa điểm, như được xác định trong Places SDK cho iOS. Ví dụ: công viên giải trí là địa điểm yêu thích, nhưng những thứ như đài phun nước thường không phải là địa điểm yêu thích (trừ phi chúng có ý nghĩa lịch sử hoặc quốc gia).
Theo dõi các sự kiện nhấp vào các địa điểm yêu thích
#import "POI.h"@importGoogleMaps;@interfacePOI()<GMSMapViewDelegate>
@end@implementationPOI-(void)loadView{GMSCameraPosition*camera=[GMSCameraPositioncameraWithLatitude:47.603longitude:-122.331zoom:14];GMSMapView*mapView=[GMSMapViewmapWithFrame:CGRectZerocamera:camera];mapView.delegate=self;self.view=mapView;}#pragma mark - GMSMapViewDelegate-(void)mapView:(GMSMapView*)mapViewdidTapPOIWithPlaceID:(NSString*)placeIDname:(NSString*)namelocation:(CLLocationCoordinate2D)location{NSLog(@"You tapped %@: %@, %f/%f",name,placeID,location.latitude,location.longitude);}@end
Hiện thông tin chi tiết trong cửa sổ thông tin
Các địa điểm yêu thích xuất hiện trên bản đồ theo mặc định, nhưng không có giao diện người dùng mặc định khi nhấp vào (API không tự động hiển thị cửa sổ thông tin hoặc bất kỳ giao diện người dùng nào khác khi người dùng nhấn vào một địa điểm yêu thích). Ví dụ sau đây cho biết cách sử dụng một điểm đánh dấu để hiển thị cửa sổ thông tin cho một địa điểm yêu thích:
Swift
// Declare GMSMarker instance at the class level.letinfoMarker=GMSMarker()// Attach an info window to the POI using the GMSMarker.funcmapView(_mapView:GMSMapView,didTapPOIWithPlaceIDplaceID:String,name:String,location:CLLocationCoordinate2D){infoMarker.snippet=placeIDinfoMarker.position=locationinfoMarker.title=nameinfoMarker.opacity=0;infoMarker.infoWindowAnchor.y=1infoMarker.map=mapViewmapView.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*)mapViewdidTapPOIWithPlaceID:(NSString*)placeIDname:(NSString*)namelocation:(CLLocationCoordinate2D)location{infoMarker=[GMSMarkermarkerWithPosition:location];infoMarker.snippet=placeID;infoMarker.title=name;infoMarker.opacity=0;CGPointpos=infoMarker.infoWindowAnchor;pos.y=1;infoMarker.infoWindowAnchor=pos;infoMarker.map=mapView;mapView.selectedMarker=infoMarker;}
Ngừng hiển thị các địa điểm yêu thích trên bản đồ
Bạn có thể ẩn các địa điểm yêu thích bằng cách áp dụng kiểu tuỳ chỉnh cho tất cả địa điểm yêu thích hoặc cho các danh mục địa điểm yêu thích cụ thể.
Khai báo kiểu JSON sau đây sẽ ẩn tất cả các địa điểm yêu thích của doanh nghiệp trên bản đồ:
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-09-05 UTC."],[[["\u003cp\u003ePoints of interest (POIs) such as parks, schools, and businesses are displayed on the base map by default, with business POIs appearing only in the \u003ccode\u003ekGMSTypeNormal\u003c/code\u003e map type.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can listen for click events on POIs and respond to user taps by implementing the \u003ccode\u003eGMSMapViewDelegate\u003c/code\u003e and the \u003ccode\u003emapView(_:didTapPOIWithPlaceID:name:location:)\u003c/code\u003e method.\u003c/p\u003e\n"],["\u003cp\u003eWhile POIs are shown automatically, there is no default on-click UI; developers can display an info window by using a marker and attaching it to the POI.\u003c/p\u003e\n"],["\u003cp\u003eCustom styles can be applied to hide all or specific categories of POIs on the map, such as business POIs or simplifying the display of all POIs.\u003c/p\u003e\n"]]],[],null,["Select platform: [Android](/maps/documentation/android-sdk/poi \"View this page for the Android platform docs.\") [iOS](/maps/documentation/ios-sdk/poi \"View this page for the iOS platform docs.\") [JavaScript](/maps/documentation/javascript/examples/event-poi \"View this page for the JavaScript platform docs.\")\n\n\u003cbr /\u003e\n\nBy default, points of interest (POIs) appear on the base map along with their\ncorresponding icons. POIs include parks, schools, government buildings, and\nmore. In addition, *business* POIs appear by default on the map when the map\ntype is `kGMSTypeNormal`. Business POIs represent businesses such as shops,\nrestaurants, hotels, and more.\n\nA POI corresponds to a [Place ID](/maps/documentation/places/ios-sdk/place-id#id-overview),\nas defined in the Places SDK for iOS. For example, recreational parks are POIs,\nbut things like water fountains are generally not POIs (unless they're of\nnational or historic significance).\n\nListening for click events on POIs\n\nIf you want to respond to a user tapping on a POI, implement\n[`GMSMapViewDelegate`](/maps/documentation/ios-sdk/reference/objc/Protocols/GMSMapViewDelegate),\nand implement the\n[`mapView(_:didTapPOIWithPlaceID:name:location:)`](/maps/documentation/ios-sdk/reference/objc/Protocols/GMSMapViewDelegate#-mapview:didtappoiwithplaceid:name:location:)\nmethod, as shown in the following example:\n\n\nSwift \n\n```swift\nimport GoogleMaps\n\nclass POI: UIViewController, GMSMapViewDelegate {\n\n override func loadView() {\n let camera = GMSCameraPosition.camera(\n withLatitude: 47.603,\n longitude:-122.331,\n zoom:14\n )\n let mapView = GMSMapView.map(withFrame: .zero, camera: camera)\n mapView.delegate = self\n self.view = mapView\n }\n\n func mapView(\n _ mapView: GMSMapView,\n didTapPOIWithPlaceID placeID: String,\n name: String,\n location: CLLocationCoordinate2D\n ) {\n print(\"You tapped \\(name): \\(placeID), \\(location.latitude)/\\(location.longitude)\")\n }\n}\n \n```\n\nObjective-C \n\n```objective-c\n#import \"POI.h\"\n@import GoogleMaps;\n\n@interface POI () \u003cGMSMapViewDelegate\u003e\n\n@end\n\n@implementation POI\n\n- (void)loadView {\n GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:47.603\n longitude:-122.331\n zoom:14];\n GMSMapView *mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];\n mapView.delegate = self;\n self.view = mapView;\n}\n\n#pragma mark - GMSMapViewDelegate\n\n- (void)mapView:(GMSMapView *)mapView\n didTapPOIWithPlaceID:(NSString *)placeID\n name:(NSString *)name\n location:(CLLocationCoordinate2D)location {\n NSLog(@\"You tapped %@: %@, %f/%f\", name, placeID, location.latitude, location.longitude);\n}\n\n@end\n \n```\n\n\u003cbr /\u003e\n\nShowing details in an info window\n\nPOIs appear on the map by default, but there is no default on-click UI (the API\ndoes not automatically display an info window or any other user interface when\nthe user taps a POI). The following example shows how to use a marker to\ndisplay an info window for a POI:\n\n\nSwift \n\n```swift\n// Declare GMSMarker instance at the class level.\nlet infoMarker = GMSMarker()\n\n// Attach an info window to the POI using the GMSMarker.\nfunc mapView(\n _ mapView: GMSMapView,\n didTapPOIWithPlaceID placeID: String,\n name: String,\n location: CLLocationCoordinate2D\n) {\n infoMarker.snippet = placeID\n infoMarker.position = location\n infoMarker.title = name\n infoMarker.opacity = 0;\n infoMarker.infoWindowAnchor.y = 1\n infoMarker.map = mapView\n mapView.selectedMarker = infoMarker\n}\n \n```\n\nObjective-C \n\n```objective-c\n// Declare a GMSMarker instance at the class level.\nGMSMarker *infoMarker;\n\n// Attach an info window to the POI using the GMSMarker.\n- (void)mapView:(GMSMapView *)mapView\n didTapPOIWithPlaceID:(NSString *)placeID\n name:(NSString *)name\n location:(CLLocationCoordinate2D)location {\n infoMarker = [GMSMarker markerWithPosition:location];\n infoMarker.snippet = placeID;\n infoMarker.title = name;\n infoMarker.opacity = 0;\n CGPoint pos = infoMarker.infoWindowAnchor;\n pos.y = 1;\n infoMarker.infoWindowAnchor = pos;\n infoMarker.map = mapView;\n mapView.selectedMarker = infoMarker;\n}\n \n```\n\n\u003cbr /\u003e\n\nStopping POIs from showing on the map\n\nYou can hide POIs by applying custom styles to all POIs or\nto specific categories of POIs.\n\nThe following JSON style declaration hides all business POIs on the map: \n\n [\n {\n \"featureType\": \"poi.business\",\n \"stylers\": [\n { \"visibility\": \"off\" }\n ]\n }\n ]\n\nAs another example, the following JSON simplifies the display of all categories\nof POIs: \n\n [\n {\n \"featureType\": \"poi\",\n \"stylers\": [\n { \"visibility\": \"simplified\" }\n ]\n }\n ]\n\nFor more details, see the guide to [hiding map features with styling](/maps/documentation/ios-sdk/hiding-features)."]]