【发布时间】:2020-08-27 23:41:21
【问题描述】:
目前正在为一家公司创建应用程序。应用程序的用户显示在地图上,他们的宠物也应该显示在地图上。 @react-native-community/geolocation给你以下信息
coords: {
accuracy: 5
altitude: 0
altitudeAccuracy: -1
heading: -1
latitude: 37.7873589
longitude: -122.408227
speed: -1
}
我正在与另一家公司的开发人员合作,他希望我提供以下信息,以便发送宠物位置。
{
"bounds": {
"northeast": {
"latitude": 0,
"longitude": 0
},
"southwest": {
"latitude": 0,
"longitude": 0
}
},
"showVets": true,
"showSightings": true,
"showLostPets": true,
"showDogs": true,
"showCats": true,
"showOtherPetTypes": true
}
地理位置不会为您提供northeast 和southwest 坐标。我不确定要告诉开发人员什么,以便他可以更新 API,向我发送正确的信息。任何帮助将不胜感激。
更新:
我试图创建一个函数来生成northeast 和southwest 坐标。
const region = {
latitude: 37.78825,
longitude: -122.4324,
latitudeDelta: 0.0922,
longitudeDelta: 0.0421,
}
const getMapBoundaries = (region) => {
const northEast = {
latitude: region.latitude + region.latitudeDelta / 2,
longitude: region.longitude + region.longitudeDelta / 2
}
const southWest = {
latitude: region.latitude - region.latitudeDelta / 2,
longitude: region.longitude - region.longitudeDelta / 2
}
return {northEast, southWest}
}
我相信我在某个地方。如何改进此功能以获得准确的坐标?
【问题讨论】:
标签: reactjs react-native geolocation