2017-02-01 13 views
1

iOSアプリケーションで使用するGoogle Maps SDKのMyLocationButtonの位置を変更する必要があります。試しましたiOSのGoogleマップでMyLocationButtonの位置を変更する

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

ボタンのorigin.yを取得するには、そうしないでください。座標を得ることは可能ですか?

答えて

1

マップビュー上に新しいボタンを追加することで、1つの方法で行うことができます。

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) 
} 
関連する問題