GMSMapView,didTapPOIWithPlaceID不显示业务POI
问题描述:
我显示的是GMSMapView
,但无法实现显示的餐厅,酒店,商店等营业场所。根据docs使用mapType kGMSTypeNormal
应提供该请求。GMSMapView,didTapPOIWithPlaceID不显示业务POI
In addition, business POIs appear by default on the map when the map type is kGMSTypeNormal
不幸的是,它只显示“官方”的兴趣点,如公园,景点,医院等。
此外,我会预计,当我点击这些“官方”POI中的一个时,会调用GMSMapViewDelegate
成员函数mapView:didTapPOIWithPlaceID:name:location:
,但无论我在哪里点击,我都不会获得要调用的函数。我暂时尝试了相应的mapView:didTapAtCoordinate:
只是为了确保我正确设置了代表,并且完美地工作。
这里是我的代码:
import UIKit
import GoogleMaps
class PoiGoogleMapVC: UIViewController, UITextFieldDelegate, CLLocationManagerDelegate, GMSMapViewDelegate {
@IBOutlet weak var mainMap: GMSMapView!
let locationManager = CLLocationManager()
override func viewDidLoad() {
super.viewDidLoad()
mainMap.delegate = self
locationManager.delegate = self
let camera: GMSCameraPosition = GMSCameraPosition.camera(withLatitude: 48.857165, longitude: 2.354613, zoom: 8.0)
self.mainMap.mapType = kGMSTypeNormal
self.mainMap.camera = camera
locationManager.requestWhenInUseAuthorization()
}
func mapView(_ mapView: GMSMapView, didTapPOIWithPlaceID placeID: String, name: String, location: CLLocationCoordinate2D) {
print("You tapped \(name): \(placeID), \(location.latitude)/\(location.longitude)")
}
}
什么可能是一个暗示,解决方案,但在这一点上唯一让我困惑,是根据api docGMSMapView
有一个名为mapStyle
属性。当我尝试访问该属性的Xcode给了我一个编译器错误:在2.1版本中加入
Value of type 'GMSMapView' has no member 'mapStyle'
答
的mapStyle
和业务的POI,发布了9月22日2016年在这里看到:
https://developers.google.com/maps/documentation/ios-sdk/releases#version_21_-_september_22_2016
也许你有一个旧版本的SDK?
这是正确的答案。这也是我的怀疑,但是由于我从头开始安装它,我无法相信它。事实证明,如果你在'pod install'之后立即执行'pod update',它就不会受到伤害(有时可能非常有用)。谢谢! – tr03lf