我想总是在谷歌地图上显示交通细节,我搜索了很多,我找到的唯一解决方案是。
设置为isTrafficEnabled
GMSMapView
属性的true。但它不起作用,我的地图视图不显示交通细节。
有我的代码show MapView
,有人知道问题出在哪里了吗?
fileprivate func initMapView() {
mapView.animate(toLocation: CLLocationCoordinate2D(latitude: originlocationlan,longitude: originlocationlng))
mapView.animate(toZoom: 20)
self.mapView.delegate = self
mapView.mapType = .normal
mapView.isTrafficEnabled = true
mapView.settings.zoomGestures = true
mapView.settings.rotateGestures = true
}
override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
if !didFindMyLocation {
print("if allow access to location")
let mylocation : CLLocation = change![NSKeyValueChangeKey.newKey] as! CLLocation
myLat = mylocation.coordinate.latitude
myLon = mylocation.coordinate.longitude
mapView.camera = GMSCameraPosition.camera(withTarget: mylocation.coordinate, zoom: 15.0)
registerGetAddressForCenterCoordinateOfMap(lat: mylocation.coordinate.latitude, lng: mylocation.coordinate.longitude)
mapView.animate(toZoom: 15.0)
mapView.settings.myLocationButton = true
mapView.settings.allowScrollGesturesDuringRotateOrZoom = true
mapView.settings.indoorPicker = true
didFindMyLocation = true
}
}