【问题标题】:Google-maps-api Generate list of users proximity to master list of locationsGoogle-maps-api 生成与位置主列表接近的用户列表
【发布时间】:2017-10-16 16:31:05
【问题描述】:

我有一个位置列表“A”和一个用户列表“B”,我需要从“C”生成一个列表。

我需要能够查看 B 中的哪些用户位于列表“A”中位置的 1/4 英里范围内,并将其转储到可读列表(不是地图)中。

是否有一种相对简单的方法可以使用 google-maps-api 执行此操作,或者我是在找错树了吗?

顺便说一下,所有列表都是静态的。 “A”和“B”上的位置永远不会改变。

示例信息: “A”福尔摩斯侦探社 , 401 E South St, Jackson MS 39201 "B" John Watson, 400 high st, Jackson MS 39201

【问题讨论】:

  • 什么是样本输入和预期输出。请澄清
  • 在原文中添加了一个示例
  • 那么“C”是什么?您需要比较多少个位置?您如何存储您的位置(在哪里,您是否只有地址或坐标?)。您是否在这里寻找其他问题?有很多。

标签: google-maps google-maps-api-3 location proximity


【解决方案1】:

使用DistanceMatrix API

origins      = Locations list A
destinations = Users list  B

你会得到这样的回应:

{
   "destination_addresses" : [
      "user-1 address",
      "user-2 address"
   ],
   "origin_addresses" : [ 
      "location-1",
      "location-2"
   ],

   "rows" : [
      {
         "elements" : [
            {
               "distance" : {
                  "text" : "4.2 km",
                  "value" : 4247
               },
               "duration" : {
                  "text" : "16 mins",
                  "value" : 968
               },
               "status" : "OK"
            },
            {
               "distance" : {
                  "text" : "11.7 km",
                  "value" : 11670
               },
               "duration" : {
                  "text" : "31 mins",
                  "value" : 1851
               },
               "status" : "OK"
            }
         ]
      }
   ],
   "status" : "OK"
}

循环通过 API 响应并比较 distance < x mile 你就会得到你的结果。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-06-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-06
    相关资源
    最近更新 更多