如何自定义Google Maps for iOS的“myLocationButton”Swift

问题描述:

我是iOS开发的新手。我想创建一个自定义按钮,其功能与Google Maps SDK for iOS中的默认按钮(myLocationButton)相同。我可以这样做吗? 我可以创建按钮,但我不知道如何添加动作来跟踪我的当前位置并在屏幕中心显示标记。我使用的是斯威夫特3.如何自定义Google Maps for iOS的“myLocationButton”Swift

-Here is the image-

任何帮助,将不胜感激!如果存在,他们

func gotoMyLocationAction(sender: UIButton) 
{ 
    guard let lat = self.mapView.myLocation?.coordinate.latitude, 
      let lng = self.mapView.myLocation?.coordinate.longitude else { return } 

    let camera = GMSCameraPosition.camera(withLatitude: lat ,longitude: lng , zoom: zoom) 
    self.mapView.animate(to: camera) 
} 

该中心地图,让您的当前位置:

你可以落实在行动上,像这样。希望有所帮助。

请务必在GMSMapView位置探测有效

self.mapView.isMyLocationEnabled = true 
+0

嘿,谢谢!有效! – user1994

+0

好,它对我有帮助..!谢谢.. –