【问题标题】:Search address with openlayers使用 openlayers 搜索地址
【发布时间】:2017-12-20 16:53:17
【问题描述】:

我有一个 PHP 项目,我正在使用 openlayers 制作地图,但我需要通过传递地址列表来定位书签,它必须是免费的地理编码器,因为有很多地址。非常感谢。

【问题讨论】:

    标签: geocoding openlayers-3


    【解决方案1】:

    要免费对您的地址进行地理编码,请以这种方式将 nominatim.openstreetmap.org 地理编码器与 jquery ajax 一起使用:

    var data = {
        "format": "json",
        "addressdetails": 1,
        "q": "22 rue mouneyra bordeaux",
        "limit": 1
    };
    $.ajax({
      method: "GET",
      url: "https://nominatim.openstreetmap.org",
      data: data
    })
    .done(function( msg ) {
        console.log( msg );
    });
    

    您将收到一个美味的 json 对象:

    address: {
        city: "Bordeaux"
        country: "France"
        country_code: "fr"
        county: "Bordeaux"
        house_number: "22"
        postcode: "33000"
        road: "Rue Mouneyra"
        state: "Nouvelle-Aquitaine"
        suburb: "Saint-Augustin - Tauzin - Alphonse Dupeux"
    }
    boundingbox:["44.8341251", "44.8342251", "-0.581869", "-0.581769"]
    class: "place"
    display_name: "22, Rue Mouneyra, Saint-Augustin - Tauzin - Alphonse Dupeux, Bordeaux, Gironde, Nouvelle-Aquitaine, France métropolitaine, 33000, France"
    importance: 0.411
    lat: "44.8341751"
    licence: "Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright"
    lon: "-0.581819"
    osm_id: "2542169758"
    osm_type: "node"
    place_id: "26453710"
    type: "house"
    

    然后您可以在一个循环中对多个位置进行地理编码。

    干杯

    【讨论】:

    • 我正在阅读有关 nominatim 的信息,它看起来限制为每秒 1 个查询,因此这可能无助于对整个地址列表进行地理编码。
    • 是的,如果你做的请求太多,你会被禁止,所以在循环中你必须插入一个超时,或者延迟。
    【解决方案2】:

    你可以使用这样的东西:

    1. Search bar

      • 在图层中搜索特征
      • 在地图上搜索地点
    2. Search features

    享受:)

    【讨论】:

    • 链接已损坏
    猜你喜欢
    • 2017-02-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-29
    • 2017-11-30
    • 2011-04-06
    • 2016-03-05
    • 1970-01-01
    相关资源
    最近更新 更多