如何在React Native中更改Map坐标格式?

问题描述 投票:1回答:1

在firestore数据库中,我的位置以这种形式存储 - 位置:[30.4345685454346°N,2.134343291302°W]

当我取出它时,如何从坐标中移除°N和°W?

此外,使用location: new GeoPoint(position.latitude, position.longitude)这种方式将坐标设置到Firestore api中

react-native google-cloud-firestore react-native-maps react-native-firebase
1个回答
0
投票

GeoPoint基本上是firebase的对象类型,用于存储纬度和经度。我假设你安装了react-native-firebase。然后您可以按如下方式检索纬度和经度

const yourGeoPoint = new firebase.firestore.GeoPoint(someLatitude, someLongitude);

const latitude = yourGeoPoint.latitude; // this will give the latitude
const longitude = yourGeoPoint. longitude; // this will give the longitude

有关这方面的更多文档可以在https://rnfirebase.io/docs/v5.x.x/firestore/reference/GeoPoint找到

© www.soinside.com 2019 - 2024. All rights reserved.