【问题标题】:How do i parse latitude and longitude to google maps?如何将纬度和经度解析到谷歌地图?
【发布时间】:2016-06-05 00:45:41
【问题描述】:

我的目标是解析 lat 和 long 到谷歌地图,假设 mapView 是 GMSMapView 类的视图对象,我已经初始化了它。

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

每当我运行它时,它都不会显示自定义坐标的标记

【问题讨论】:

    标签: ios swift google-maps google-maps-sdk-ios


    【解决方案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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-26
      相关资源
      最近更新 更多