如何检查坐标并将其加载到 Google 地图 (iOS) 中?

How to check and load coordinate into Google Map (iOS)?

我在数据库中有一个坐标列表,但我只想加载当前在 Google 地图视图中的坐标并在其上添加标记。我该怎么做?

获得纬度和经度后,您可以使用以下函数添加地图标记并缩放到标记位置:

func showMapMarker() {
    self.currentLocationMapView.clear()

    DispatchQueue.main.async {

        let position = CLLocationCoordinate2D(latitude: latitude, longitude: longitude)
        let marker = GMSMarker(position: position)
        let bounds: GMSCoordinateBounds = GMSCoordinateBounds(coordinate: position, coordinate: position)
        marker.title = "Snippet Title"
        marker.map = self.currentLocationMapView
        marker.snippet = "Snippet Text"
        let camera = self.currentLocationMapView.camera(for: bounds, insets: UIEdgeInsets())
        self.currentLocationMapView.animate(with: GMSCameraUpdate.fit(bounds, withPadding: 15.0))
        self.currentLocationMapView.camera = camera!
    }
}