我在ios swift 4.1中的google地图上为自定义窗口信息编写此方法,但是在谷歌地图上显示的窗口
我也设置了代表,但没有结果
func mapView(_mapView: GMSMapView, markerInfoWindow marker: GMSMarker) -> UIView?{
let infoWindow: InfoWindow = Bundle.main.loadNibNamed("InfoWindow", owner: self.view, options: nil)!.first! as! InfoWindow
infoWindow.numberCarLabel.text = "TLA-618"
infoWindow.dateLabel.text = "2018-05-02 10:39:43"
infoWindow.digreeLabel.text = "94"
infoWindow.addressLabel.text = "Sunrise Appartments, Marine Promenade, Karachi"
infoWindow.kilometterLabel.text = "0"
return infoWindow
}
答案 0 :(得分:1)
检查完代码后确定,首先你在代理功能名称
中输入了拼写错误正确的是:
func mapView(_ mapView: GMSMapView, markerInfoWindow marker: GMSMarker) -> UIView? {
let infoWindow: InfoWindow = Bundle.main.loadNibNamed("InfoWindow", owner: self.view, options: nil)!.first! as! InfoWindow
infoWindow.numberCarLabel.text = "TLA-618"
infoWindow.dateLabel.text = "2018-05-02 10:39:43"
infoWindow.digreeLabel.text = "94"
infoWindow.addressLabel.text = "Sunrise Appartments, Marine Promenade, Karachi"
infoWindow.kilometterLabel.text = "0"
return infoWindow
}
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation])
您还需要在每次CLLocationManager
报告位置
将此func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation])
实施替换为此
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
let userLocation = locations.last
let camera = GMSCameraPosition.camera(withLatitude: userLocation!.coordinate.latitude,
longitude: userLocation!.coordinate.longitude, zoom: 13.0)
mapView.isMyLocationEnabled = true
self.mapView.animate(to: camera)
locationManager.stopUpdatingLocation()
}