【问题标题】:Google Maps API for iOS - Marker is not displayed适用于 iOS 的 Google Maps API - 不显示标记
【发布时间】:2019-12-03 02:22:04
【问题描述】:

我是 iOS 编码的新手,我想在我的 Swift 应用程序中创建一个带有路径/方式的地图。在尝试应用 KML 覆盖后,它不起作用,我决定使用折线。但是折线也没有显示,所以我尝试了一个标记,完全按照https://developers.google.com/maps/documentation/ios-sdk/marker 的教程进行操作,但标记也没有显示。我究竟做错了什么?这是我的标记代码:

import UIKit
import GoogleMaps

class MapViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad() 

        GMSServices.provideAPIKey("MY_KEY")

        let camera = GMSCameraPosition.camera(withLatitude: 48.194857, longitude: 13.955710, zoom: 17)
        let mapView = GMSMapView.map(withFrame: .zero, camera: camera)
        mapView.mapType = .satellite
        mapView.setMinZoom(17, maxZoom: 19)
        view = mapView


        let marker = GMSMarker()
        marker.position = CLLocationCoordinate2D(latitude: 13.9553836,longitude: 48.1956954)
        marker.title = "Hello World"
        marker.map = mapView 

        // Do any additional setup after loading the view.
    }

}

提前谢谢你!

【问题讨论】:

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


    【解决方案1】:

    我认为代码没问题,但标记不可见,因为它位于世界的另一部分。 尝试交换标记的纬度和经度 marker.position = CLLocationCoordinate2D(纬度:13.9553836,经度:48.1956954)

    或者为您的地图设置较低的缩放比例

    【讨论】:

    • 你是什么意思 尝试你的标记的纬度和经度 marker.position = CLLocationCoordinate2D(latitude: 13.9553836,longitude: 48.1956954)
    • 我刚刚注意到问题:我已经切换了纬度和经度。抱歉这个问题!
    猜你喜欢
    • 1970-01-01
    • 2015-07-01
    • 2018-03-13
    • 2014-02-13
    • 1970-01-01
    • 2017-02-16
    • 2014-07-29
    • 2018-01-03
    • 1970-01-01
    相关资源
    最近更新 更多