【问题标题】:Using React Native Geolocation how do I get other users to display on map?使用 React Native Geolocation 如何让其他用户在地图上显示?
【发布时间】: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
}

地理位置不会为您提供northeastsouthwest 坐标。我不确定要告诉开发人员什么,以便他可以更新 API,向我发送正确的信息。任何帮助将不胜感激。

更新:

我试图创建一个函数来生成northeastsouthwest 坐标。

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


    【解决方案1】:

    只需为两者发送相同的值。听起来他们在要求您可能在其中的边界矩形范围。您没有范围,您有一个确切的位置。

    否则,您必须与其他开发人员确认您的位置应该有多“模糊”,然后将其添加到两者中。

    如果要宠物或其他什么,则由您来定义界限。如果您想要在纬度和经度方面与您的位置偏移 1 度的范围内的所有内容,请将东北的纬度/经度加 1,西南的减去它。

    【讨论】:

    • 您的回复。我与另一位开发人员交谈,我猜他应该获取我的坐标并围绕该坐标创建一个半径。我的工作是向他发送用户的位置。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-02-01
    • 1970-01-01
    • 1970-01-01
    • 2023-01-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多