问题描述
当前正在为公司创建应用程序。该应用程序的用户显示在地图上,并且他们的宠物也应该显示在地图上。 @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}
}
我相信我不在某个地方。如何改善此功能以获得准确的坐标?
解决方法
只需为两者发送相同的值。听起来好像他们在要求您可能所在的矩形范围。您没有范围,您有确切的位置。
否则,您必须与其他开发人员确认您的位置应该有多“模糊”,然后将其添加到两者中。
如果您要要宠物或其他任何东西,则要由您来定义范围。如果您希望所有东西都在经度和纬度之间偏移您的位置1度,请为东北增加lat / long到1,向西南减去lat / long。