2016-06-04 3 views
0

내 목표는 Google지도에 위도와 경도를 파싱하는 것입니다. mapViewGMSMapView 클래스의 뷰 객체이고이를 초기화했습니다.Google지도에서 위도와 경도를 어떻게 파싱합니까?

override func viewDidLoad() { 
    super.viewDidLoad() 
    locationManager.delegate = self 
     // Ask for Authorisation from the User. 
    self.locationManager.requestAlwaysAuthorization() 
    // For use in foreground 
    self.locationManager.requestWhenInUseAuthorization() 

    // This is where I will parse the lat and long 
    var coordinate: CLLocationCoordinate2D 
    coordinate = CLLocationCoordinate2D(latitude: 3.203119, longitude: 101.7276145) 
    mapView.projection.containsCoordinate(coordinate) 
} 

나는 그것을 실행할 때마다, 사용자의 마커가

답변

1
let camera = GMSCameraPosition.cameraWithLatitude(yourLatitude, 
                 longitude: yourLongitude, zoom: 15) 
    mapView = GMSMapView.mapWithFrame(CGRectZero, camera: camera) 
    mapView.myLocationEnabled = true 
    mapView.delegate = self 
    mapView.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) 
    self.view.addSubview(mapView) 



    let marker = GMSMarker() 
    marker.position = CLLocationCoordinate2DMake(yourLatitude, yourLongitude) 
    marker.title = strTitleOfMarker 
    marker.snippet = strSubTitleOfMarker 
    marker.map = mapView 



// Add this to .plist file 
<key>NSLocationAlwaysUsageDescription</key> 
<string>Access your location</string> 
좌표를 표시하지 않습니다
관련 문제