【发布时间】:2017-11-30 16:24:17
【问题描述】:
我使用的是 xcode 9.0、GoogleMaps SDK 2.5.0 和 GooglePlaces 2.5.0。
在func mapView(_ mapView: GMSMapView, didTap marker: GMSMarker) -> Bool 方法中,当我选择一个标记并返回到仅显示标记且未启用自动中心的旧行为时,我正在尝试禁用自动居中地图。问题是当我实现该行为(已注释的行)时标记没有出现,我搜索的所有堆栈溢出都实现了这些行。我迷路了
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
}
}
【问题讨论】:
标签: ios swift google-maps marker gmsmapview