gpt4 book ai didi

java - 如何从 firestore 检索我的 Geopoint 对象

转载 作者:行者123 更新时间:2023-12-02 09:51:39 30 4
gpt4 key购买 nike

我正在使用 Firestore 的 Geopoint object 保存当前设备位置.

检索它时,如下所示(toString()):

{geoPoint=GeoPoint { 纬度=-1.2968733, 经度=36.8906349 }}

如何检索纬度和经度?

最佳答案

如果您知道该字段是 GeoPoint 类型对象,只需将其作为 GeoPoint 类型字段获取,然后使用其 getLatitude 和 getLongitude 方法来访问这些值。不必费心将其转换为字符串。

GeoPoint gp = snapshot.getGeoPoint("your-field");
double lat = gp.getLatitude();
double lon = gp.getLongitude();

关于java - 如何从 firestore 检索我的 Geopoint 对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56279552/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com