2017-02-01 1 views

Antwort

1

eine Möglichkeit, dies zu tun, indem eine neue Schaltfläche über die Kartenansicht hinzugefügt wird.

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) 
} 
Verwandte Themen