当我点击标记时,谷歌地图的旧行为
GoogleMaps old behaviour, when I tap a marker
我正在使用 xcode 9.0、GoogleMaps SDK 2.5.0 和 GooglePlaces 2.5.0。
在方法 func mapView(_ mapView: GMSMapView, didTap marker: GMSMarker) -> Bool
中,我试图禁用自动居中地图,当我 select 标记并返回到仅显示标记且未启用自动居中的旧行为时.问题是当我实现该行为时标记没有出现(注释行),我搜索的所有堆栈溢出都实现了这些行。我迷路了
class MapViewController: UIViewController, GMSMapViewDelegate
{
//MARK: Class Life Cycle
@IBOutlet weak var mapView: UIView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
setupUI()
setupMap()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
//MARK: -Setup
func setupUI() {
navigationController?.hideBar()
}
func setupMap() {
let map = MapManager.sharedInstance.setupMap(view: mapView, latitude: GoogleMap.latitude, longitude: GoogleMap.longitude, zoom: GoogleMap.zoom)
map.delegate = self
mapView.addSubview(map)
MapManager.sharedInstance.setupMapMarkers(map: map, file: File.geoFence, fileType: File.json)
}
func mapView(_ mapView: GMSMapView, didTap marker: GMSMarker) -> Bool {
// mapView.selectedMarker = marker
// return true
return false
}
}
如果有人遇到这个奇怪的错误,奇怪的解决方案是再次添加委托:
func mapView(_ mapView: GMSMapView, didTap marker: GMSMarker) -> Bool {
mapView.delegate = self
mapView.selectedMarker = marker
return true
return false
}
我正在使用 xcode 9.0、GoogleMaps SDK 2.5.0 和 GooglePlaces 2.5.0。
在方法 func mapView(_ mapView: GMSMapView, didTap marker: GMSMarker) -> Bool
中,我试图禁用自动居中地图,当我 select 标记并返回到仅显示标记且未启用自动居中的旧行为时.问题是当我实现该行为时标记没有出现(注释行),我搜索的所有堆栈溢出都实现了这些行。我迷路了
class MapViewController: UIViewController, GMSMapViewDelegate
{
//MARK: Class Life Cycle
@IBOutlet weak var mapView: UIView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
setupUI()
setupMap()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
//MARK: -Setup
func setupUI() {
navigationController?.hideBar()
}
func setupMap() {
let map = MapManager.sharedInstance.setupMap(view: mapView, latitude: GoogleMap.latitude, longitude: GoogleMap.longitude, zoom: GoogleMap.zoom)
map.delegate = self
mapView.addSubview(map)
MapManager.sharedInstance.setupMapMarkers(map: map, file: File.geoFence, fileType: File.json)
}
func mapView(_ mapView: GMSMapView, didTap marker: GMSMarker) -> Bool {
// mapView.selectedMarker = marker
// return true
return false
}
}
如果有人遇到这个奇怪的错误,奇怪的解决方案是再次添加委托:
func mapView(_ mapView: GMSMapView, didTap marker: GMSMarker) -> Bool {
mapView.delegate = self
mapView.selectedMarker = marker
return true
return false
}