【发布时间】:2019-06-14 20:08:28
【问题描述】:
我正在尝试在谷歌地图上显示位置,我从 Firestore 获取经度和纬度。
我创建了一个存储经纬度的结构
struct Location {
var latitude: String = ""
var longitute: String = ""
}
这是我获取经度和纬度的 Firestore 代码
for document in snapshot!.documents {
self.location.append(Location(latitude: "\(document.data()["Latitude"] ?? "")", longitute: "\(document.data()["longitude"] ?? "")"))
print(self.location)
guard let long = document.data()["Latitude"] as? String else { return}
guard let lat = document.data()["longitude"] as? String else { return}
let markerStart = GMSMarker(position: CLLocationCoordinate2D(latitude: Double(long) ?? 0.0, longitude: Double(lat) ?? 0.0))
markerStart.map = self.mapView
}
我在控制台中获取位置,但是当我将其转换为双打试图在谷歌地图上显示它时,它不起作用。请帮忙?
Document Value is ["userid": 24xDkrtBV6cJrBvRD3U0PmyBF3o2, "createddatetime": FIRTimestamp: seconds=1546584489 nanoseconds=461000000>, "user_role": sales man, "Latitude": 20.6108261, "longitude": 72.9269003, "batterypercentage": 66, "name": Keyur , "company_code": 001]
【问题讨论】:
-
请打印您的文件价值。
-
@DixitAkabari...编辑了我的问题
-
您是否在不添加标记的情况下检查地图加载是否正确?
-
加载正常
标签: ios swift google-maps google-cloud-firestore