Mapbox 映射框:查找具有定义半径的POI

Mapbox 映射框:查找具有定义半径的POI,mapbox,Mapbox,我需要的任务是: 输入:来自gps的地理位置坐标,半径 输出:用户可以选择的POI名称列表 只是需要谷歌附近的搜索模拟,因为他们的成本太高,生产 问题: 1对于这一点,哪种API更可取?请举例说明 2我是否需要自己的POI数据,或者mapbox中是否有用于这些目的的内置日期?允许您准确地执行此操作。是一个循序渐进的教程,解释如何使用此API,并让您尝试使用该API。API查询的数据由作为参数传递给API请求的tileset确定。如链接文档、教程和游乐场中所述,您可以使用现有的Mapbox瓷砖集,

我需要的任务是:

输入:来自gps的地理位置坐标,半径

输出:用户可以选择的POI名称列表

只是需要谷歌附近的搜索模拟,因为他们的成本太高,生产

问题:

1对于这一点,哪种API更可取?请举例说明

2我是否需要自己的POI数据,或者mapbox中是否有用于这些目的的内置日期?

允许您准确地执行此操作。是一个循序渐进的教程,解释如何使用此API,并让您尝试使用该API。API查询的数据由作为参数传递给API请求的tileset确定。如链接文档、教程和游乐场中所述,您可以使用现有的Mapbox瓷砖集,也可以使用自定义数据创建自己的瓷砖集,具体取决于您的用例

请注意,根据您使用的tileset中底层数据的结构,您可能需要做一些额外的工作来将Tilequery API返回的功能转换为POI的名称。例如,考虑以下API请求的响应体,它使用默认的MAPBOX.MAPBOX Struts -V8 TreSeTe:

响应主体返回的一个特定特性是:

{
  "type": "Feature",
  "id": 4,
  "geometry": {
  "type": "Point",
  "coordinates": [
    -93.12041537130386,
    44.947199821761615
  ]
  },
  "properties": {
    "extrude": "true",
    "height": 3,
    "min_height": 0,
    "type": "house",
    "underground": "false",
    "tilequery": {
      "distance": 1.2132887872688276,
      "geometry": "polygon",
      "layer": "building"
    }
  }
}

虽然此处没有POI名称,但您可以将返回的坐标与一起使用,以检索位于该坐标处的POI的名称和其他相关POI属性。

与Mapbox支持人员的对话

嗨,阿尔特米​,

我是Mapbox支持部门的Alex,很高兴为您提供帮助

您需要使用Mapbox Tilequery API。您要使用的选项是半径​. 请注意,查询将使用来自瓷砖集最大缩放的瓷砖,并且在搜索附近特征时仅包括相交瓷砖加上八个周围瓷砖。这意味着如果你的tileset的最大范围是z20,那么你可以搜索的最大半径只有几米。这里是一个API游乐场,您可以使用它来测试API

我希望这是有帮助的

嗨,亚历克斯

感谢您的快速回复,还有一个问题:

请求:

https://api.mapbox.com/v4/mapbox.mapbox-streets-v8/tilequery/55.9414,54.7295.json?radius=25&limit=50&deplicate&geometry=point&access\u-token=YOUR\u-MAPBOX\u-access\u-token

答复:

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "id": 8,
      "geometry": {
        "type": "Point",
        "coordinates": [
          55.94845533370972,
          54.72732387401962
        ]
      },
      "properties": {
        "house_num": "32",
        "tilequery": {
          "distance": 8.949637333832088,
          "geometry": "point",
          "layer": "housenum_label"
        }
      }
    },
    {
      "type": "Feature",
      "id": 23629792230,
      "geometry": {
        "type": "Point",
        "coordinates": [
          55.948566645383835,
          54.72761119224691
        ]
      },
      "properties": {
        "class": "general",
        "filterrank": 4,
        "maki": "marker",
        "name": "Башинформсвязь",
        "name_script": "Cyrillic",
        "sizerank": 16,
        "type": "Telecommunication",
        "tilequery": {
          "distance": 23.898768437893523,
          "geometry": "point",
          "layer": "poi_label"
        }
      }
    }
  ]
}
{  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "id": 32316157590,
      "geometry": {
        "type": "Point",
        "coordinates": [
          55.94142526388168,
          54.7295828683082
        ]
      },
      "properties": {
        "category_en": "Supermarket",
        "category_zh-Hans": "超市",
        "class": "food_and_drink_stores",
        "filterrank": 1,
        "maki": "grocery",
        "name": "Магнит",
        "name_script": "Cyrillic",
        "sizerank": 16,
        "type": "Supermarket",
        "tilequery": {
          "distance": 9.367370433680872,
          "geometry": "point",
          "layer": "poi_label"
        }
      }
    }
  ]
}
{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "id": 5,
      "geometry": {
        "type": "Point",
        "coordinates": [
          55.9485,
          54.7275
        ]
      },
      "properties": {
        "extrude": "true",
        "height": 15,
        "min_height": 0,
        "type": "building",
        "underground": "false",
        "tilequery": {
          "distance": 0,
          "geometry": "polygon",
          "layer": "building"
        }
      }
    },
    {
      "type": "Feature",
      "id": 1297495121,
      "geometry": {
        "type": "Point",
        "coordinates": [
          55.94833781213748,
          54.727526546045794
        ]
      },
      "properties": {
        "class": "path",
        "iso_3166_1": "RU",
        "iso_3166_2": "RU-BA",
        "len": 4450,
        "oneway": "false",
        "structure": "none",
        "surface": "paved",
        "type": "footway",
        "tilequery": {
          "distance": 10.859473551200084,
          "geometry": "linestring",
          "layer": "road"
        }
      }
    },
    {
      "type": "Feature",
      "id": 23629792230,
      "geometry": {
        "type": "Point",
        "coordinates": [
          55.948566645383835,
          54.72761119224691
        ]
      },
      "properties": {
        "class": "general",
        "filterrank": 4,
        "maki": "marker",
        "name": "Башинформсвязь",
        "name_script": "Cyrillic",
        "sizerank": 16,
        "type": "Telecommunication",
        "tilequery": {
          "distance": 13.10152056398561,
          "geometry": "point",
          "layer": "poi_label"
        }
      }
    },
    {
      "type": "Feature",
      "id": 7,
      "geometry": {
        "type": "Point",
        "coordinates": [
          55.94869895433047,
          54.7274698331467
        ]
      },
      "properties": {
        "extrude": "true",
        "height": 3,
        "min_height": 0,
        "type": "building",
        "underground": "false",
        "tilequery": {
          "distance": 13.251093067012334,
          "geometry": "polygon",
          "layer": "building"
        }
      }
    }
  ]
}
问题:我知道我可以使用反向地理编码API在回复中找到关于我所处位置的信息,但有其他方法可以做到这一点吗?理想情况下,我希望从一个tilquery请求中获取poi的名称,因为如果使用两个API的tilquery+地理编码,我将不得不查询4-5个查询,而不仅仅是1个查询,因为这会影响成本

嗨,阿尔特米​,

Tilequery API中有一个名为layers的参数,可用于针对样式的特定层

https://api.mapbox.com/v4/mapbox.mapbox-streets-v8/tilequery/55.9414,54.7295.json?radius=25&limit=50&dedupe&geometry=point&layers=poi_label&access_token=
这将得到以下响应:

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "id": 8,
      "geometry": {
        "type": "Point",
        "coordinates": [
          55.94845533370972,
          54.72732387401962
        ]
      },
      "properties": {
        "house_num": "32",
        "tilequery": {
          "distance": 8.949637333832088,
          "geometry": "point",
          "layer": "housenum_label"
        }
      }
    },
    {
      "type": "Feature",
      "id": 23629792230,
      "geometry": {
        "type": "Point",
        "coordinates": [
          55.948566645383835,
          54.72761119224691
        ]
      },
      "properties": {
        "class": "general",
        "filterrank": 4,
        "maki": "marker",
        "name": "Башинформсвязь",
        "name_script": "Cyrillic",
        "sizerank": 16,
        "type": "Telecommunication",
        "tilequery": {
          "distance": 23.898768437893523,
          "geometry": "point",
          "layer": "poi_label"
        }
      }
    }
  ]
}
{  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "id": 32316157590,
      "geometry": {
        "type": "Point",
        "coordinates": [
          55.94142526388168,
          54.7295828683082
        ]
      },
      "properties": {
        "category_en": "Supermarket",
        "category_zh-Hans": "超市",
        "class": "food_and_drink_stores",
        "filterrank": 1,
        "maki": "grocery",
        "name": "Магнит",
        "name_script": "Cyrillic",
        "sizerank": 16,
        "type": "Supermarket",
        "tilequery": {
          "distance": 9.367370433680872,
          "geometry": "point",
          "layer": "poi_label"
        }
      }
    }
  ]
}
{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "id": 5,
      "geometry": {
        "type": "Point",
        "coordinates": [
          55.9485,
          54.7275
        ]
      },
      "properties": {
        "extrude": "true",
        "height": 15,
        "min_height": 0,
        "type": "building",
        "underground": "false",
        "tilequery": {
          "distance": 0,
          "geometry": "polygon",
          "layer": "building"
        }
      }
    },
    {
      "type": "Feature",
      "id": 1297495121,
      "geometry": {
        "type": "Point",
        "coordinates": [
          55.94833781213748,
          54.727526546045794
        ]
      },
      "properties": {
        "class": "path",
        "iso_3166_1": "RU",
        "iso_3166_2": "RU-BA",
        "len": 4450,
        "oneway": "false",
        "structure": "none",
        "surface": "paved",
        "type": "footway",
        "tilequery": {
          "distance": 10.859473551200084,
          "geometry": "linestring",
          "layer": "road"
        }
      }
    },
    {
      "type": "Feature",
      "id": 23629792230,
      "geometry": {
        "type": "Point",
        "coordinates": [
          55.948566645383835,
          54.72761119224691
        ]
      },
      "properties": {
        "class": "general",
        "filterrank": 4,
        "maki": "marker",
        "name": "Башинформсвязь",
        "name_script": "Cyrillic",
        "sizerank": 16,
        "type": "Telecommunication",
        "tilequery": {
          "distance": 13.10152056398561,
          "geometry": "point",
          "layer": "poi_label"
        }
      }
    },
    {
      "type": "Feature",
      "id": 7,
      "geometry": {
        "type": "Point",
        "coordinates": [
          55.94869895433047,
          54.7274698331467
        ]
      },
      "properties": {
        "extrude": "true",
        "height": 3,
        "min_height": 0,
        "type": "building",
        "underground": "false",
        "tilequery": {
          "distance": 13.251093067012334,
          "geometry": "polygon",
          "layer": "building"
        }
      }
    }
  ]
}
您可以获取此响应对象并从POI返回所有信息。name属性是POI的名称。您是否正在从反向地理编码中寻找其他tilequery没有返回的属性?分享一个同时使用tilequery和反向地理编码的工作流的完整示例,并进一步了解您的确切用例,以及tilequery/反向地理编码操作如何适应更大的应用程序工作流,这将对您有所帮助

嗨,亚历克斯

请求没有poi标签,因为它找不到我知道的几个条。但如果添加此标签,则只能看到一个结果:https://api.mapbox.com/v4/mapbox.mapbox-streets-v8/tilequery/55.9485,54.7275.json?radius=14&limit=50&dedupe&access\u-token=您的\u-MAPBOX\u-access\u-token请求

答复:

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "id": 8,
      "geometry": {
        "type": "Point",
        "coordinates": [
          55.94845533370972,
          54.72732387401962
        ]
      },
      "properties": {
        "house_num": "32",
        "tilequery": {
          "distance": 8.949637333832088,
          "geometry": "point",
          "layer": "housenum_label"
        }
      }
    },
    {
      "type": "Feature",
      "id": 23629792230,
      "geometry": {
        "type": "Point",
        "coordinates": [
          55.948566645383835,
          54.72761119224691
        ]
      },
      "properties": {
        "class": "general",
        "filterrank": 4,
        "maki": "marker",
        "name": "Башинформсвязь",
        "name_script": "Cyrillic",
        "sizerank": 16,
        "type": "Telecommunication",
        "tilequery": {
          "distance": 23.898768437893523,
          "geometry": "point",
          "layer": "poi_label"
        }
      }
    }
  ]
}
{  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "id": 32316157590,
      "geometry": {
        "type": "Point",
        "coordinates": [
          55.94142526388168,
          54.7295828683082
        ]
      },
      "properties": {
        "category_en": "Supermarket",
        "category_zh-Hans": "超市",
        "class": "food_and_drink_stores",
        "filterrank": 1,
        "maki": "grocery",
        "name": "Магнит",
        "name_script": "Cyrillic",
        "sizerank": 16,
        "type": "Supermarket",
        "tilequery": {
          "distance": 9.367370433680872,
          "geometry": "point",
          "layer": "poi_label"
        }
      }
    }
  ]
}
{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "id": 5,
      "geometry": {
        "type": "Point",
        "coordinates": [
          55.9485,
          54.7275
        ]
      },
      "properties": {
        "extrude": "true",
        "height": 15,
        "min_height": 0,
        "type": "building",
        "underground": "false",
        "tilequery": {
          "distance": 0,
          "geometry": "polygon",
          "layer": "building"
        }
      }
    },
    {
      "type": "Feature",
      "id": 1297495121,
      "geometry": {
        "type": "Point",
        "coordinates": [
          55.94833781213748,
          54.727526546045794
        ]
      },
      "properties": {
        "class": "path",
        "iso_3166_1": "RU",
        "iso_3166_2": "RU-BA",
        "len": 4450,
        "oneway": "false",
        "structure": "none",
        "surface": "paved",
        "type": "footway",
        "tilequery": {
          "distance": 10.859473551200084,
          "geometry": "linestring",
          "layer": "road"
        }
      }
    },
    {
      "type": "Feature",
      "id": 23629792230,
      "geometry": {
        "type": "Point",
        "coordinates": [
          55.948566645383835,
          54.72761119224691
        ]
      },
      "properties": {
        "class": "general",
        "filterrank": 4,
        "maki": "marker",
        "name": "Башинформсвязь",
        "name_script": "Cyrillic",
        "sizerank": 16,
        "type": "Telecommunication",
        "tilequery": {
          "distance": 13.10152056398561,
          "geometry": "point",
          "layer": "poi_label"
        }
      }
    },
    {
      "type": "Feature",
      "id": 7,
      "geometry": {
        "type": "Point",
        "coordinates": [
          55.94869895433047,
          54.7274698331467
        ]
      },
      "properties": {
        "extrude": "true",
        "height": 3,
        "min_height": 0,
        "type": "building",
        "underground": "false",
        "tilequery": {
          "distance": 13.251093067012334,
          "geometry": "polygon",
          "layer": "building"
        }
      }
    }
  ]
}
如果我们使用反向地理编码来解码第一对坐标55.9485,54.7275,我们得到的是烟雾弥漫的人。俄罗斯,如果我们解码所有配对,我们将能够找到更多的咖啡馆和酒吧poi

嘿,阿特米

不同结果的原因是查询的来源

Tilequery API搜索Mapbox Streets v8 tileset上的内容,Mapbox Streets v11样式使用这些内容。此瓷砖集中的数据主要来自OpenStreetMap。如果地图上有缺失或过时的地方,这是帮助我们改进地图的绝佳机会!如果您确实想添加或编辑任何内容,请访问openstreetmap.org,创建一个帐户,并直接进行改进。您可以选择通过交互式教程开始学习。这里还有更多有关高级编辑的详细信息:。在编辑要素或将要素添加到地图时,Mapbox Streets tileset会定期更新,这意味着如果编辑OpenStreetMap,您最终将看到您的更改反映在Mapbox地图上

地理编码API包含来自政府、开放数据项目和私人公司的数据源。在某些情况下, 地理编码API的结果可能不同于Mapbox Streets或OpenStreetMap数据。查看此文档,了解Mapbox中地理编码的工作原理


我认为减少API调用量的最好方法是选择一个API,或者是反向地理编码,或者是Tilequery,并坚持使用它。使用OpenStreetMaps,尽管听起来很乏味,但您确实能够添加任何已知缺失的POI,或者交叉引用其他来源将POI添加到地图中,这将使该位置在地图上可见,并显示在您的平铺中。使用地理编码API,由于某些源和许可的性质,并不是所有可以搜索的地方都可以在地图上看到

伙计们,您好,要利用Mapbox api完成这项任务,您需要准备一组要查询的POI,我说的对吗?我很困惑——至少那个教程确实做到了这一点。非常感谢。