在iOS中的Google地图中更改MyLocationButton的位置

问题描述:

我需要更改我在iOS应用中使用的Google Maps SDK中MyLocationButton的位置。我试过在iOS中的Google地图中更改MyLocationButton的位置

for view in googleMap.subviews { 
      print(view.description) 
      print("Hello") 
     } 

要得到按钮的origin.y,但没有。是否有可能获得坐标?

通过在地图视图中添加新按钮来完成此操作的一种方法。

let googleButton = UIButton(type: UIButtonType.custom) as UIButton 
googleButton.setImage(UIImage(named: "RecenterButton"), for: .normal) 
googleButton.frame = CGRectMake(self.view.frame.size.width-60, 100, 50, 50) 
googleButton.addTarget(self, action: #selector(boundPosition), forControlEvents: .TouchUpInside) 

self.view.addSubview(googleButton) 
self.view.sendSubviewToBack(mapView) 


func boundPosition() { 
    let loc = CLLocationCoordinate2D(latitude: latitude, longitude: longitude) 

    let bounds = GMSCoordinateBounds(coordinate: loc, coordinate: loc) 
    mapView.animateWithCameraUpdate(GMSCameraUpdate.fitBounds(bounds, withPadding: 20.0)) 
    mapView.animateToZoom(15) 
    mapView.animateToViewingAngle(70) 
}