2016-12-07 1 views
0

몇 가지 다른 위치가있는지도를 표시하는 간단한 코드가 있습니다.이 코드는 클릭 한 행에 따라 달라집니다. 지도는 예상대로 표시되지만 유형을 변경하려고 할 때 위성을 사용하면지도가 사라 지지만 Google 로고는 그대로 있으므로지도에 설정 한 표시 자도 그대로 있습니다. 나는 여기에 실종 된 것이 무엇인지 알 수 없다. 여기에 몇 가지 코드가 있습니다.Google지도 유형 변경

@IBOutlet var myMapView: UIView! 
var mapView: GMSMapView? 
var currentLocation: CLLocationCoordinate2D? 
let locationManager = CLLocationManager() 
var marker = GMSMarker() 

override func viewDidLoad() { 
    super.viewDidLoad() 
    locationManager.delegate = self 
    locationManager.requestWhenInUseAuthorization() 
    locationManager.startUpdatingLocation() 

    kreirajMapu() - creates the map 
} 

func kreirajMapu() { 
    currentLocation = magacin[red].artikal[redZaMapu].lokacija 

    let camera = GMSCameraPosition.camera(withLatitude: (currentLocation?.latitude)!, longitude: (currentLocation?.longitude)!, zoom: 15) 
    mapView = GMSMapView.map(withFrame: myMapView.bounds, camera: camera) 
    mapView?.autoresizingMask = [.flexibleWidth, .flexibleHeight] 
    mapView?.isMyLocationEnabled = true 
    mapView?.settings.compassButton = true 
    mapView?.settings.myLocationButton = true 
    mapView?.settings.setAllGesturesEnabled(true) 
    myMapView.addSubview(mapView!) 
} 

func moveCamera() { 

    CATransaction.begin() 
    CATransaction.setValue(2, forKey: kCATransactionAnimationDuration) 

    mapView?.animate(to: GMSCameraPosition.camera(withTarget: magacin[red].artikal[redZaMapu].lokacija, zoom: magacin[red].artikal[redZaMapu].zoom)) 
    mapView?.animate(toViewingAngle: 45) 

    CATransaction.commit() 
    marker = GMSMarker(position: magacin[red].artikal[redZaMapu].lokacija) 
    marker.title = magacin[red].artikal[redZaMapu].naziv 
    marker.appearAnimation = kGMSMarkerAnimationPop 
    marker.snippet = "This is where \(magacin[red].artikal[redZaMapu].naziv)'s live" 
    marker.map = mapView 
} 

@IBAction func mapType(_ sender: AnyObject) { 
    let actionSheet = UIAlertController(title: "Map Types", message: "Select map type:", preferredStyle: .actionSheet) 

    actionSheet.addAction(UIAlertAction(title: "Normal", style: .default, handler: {_ in 
     self.mapView?.mapType = kGMSTypeNormal 
    })) 

    actionSheet.addAction(UIAlertAction(title: "Hybrid", style: .default, handler: {_ in 
     self.mapView?.mapType = kGMSTypeHybrid 
    })) 

    actionSheet.addAction(UIAlertAction(title: "Satellite", style: .default, handler: {_ in 
     self.mapView?.mapType = kGMSTypeSatellite 
    })) 

    actionSheet.addAction(UIAlertAction(title: "Terrain", style: .default, handler: {_ in 
     self.mapView?.mapType = kGMSTypeTerrain 
    })) 

    actionSheet.addAction(UIAlertAction(title: "Cancel", style: .cancel)) 
    present(actionSheet, animated: true, completion: nil) 
} 

답변

0

내 질문에 대한 답변은 사용하려는 앱에 대해 google.developer에서 GoogleMap API를 사용 설정해야합니다. 모든 분들께 감사드립니다./