传单:如何找到标记周围的位置?

问题描述 投票:0回答:1

我使用传单地图+传单搜索插件(https://opengeo.tech/maps/leaflet-search/examples/nominatim.html)。

因此,当我使用地图上的标记进行导航时,我想搜索标记周围的所有位置。例如,标记位于罗马(意大利),那么我想检索罗马的所有餐馆、夜总会......。

可以这样做吗?

    // click on marker
    map.on('click', function(e){  

            // update marker position
            marker.setLatLng( e.latlng);

            ....HERE CODE TO SEARCH PLACES....
 });
javascript php dictionary leaflet openstreetmap
1个回答
2
投票

@Bogza 您需要用其他库来补充此插件才能实现它。 Nominatim 是按名称搜索位置。一旦您获得了位置(经纬度),剩下的工作就取决于您了。您需要有一个包含餐厅地理位置的 geojson 或类似数据。然后您可以尝试使用以下任一库查找最近的库: https://github.com/makinacorpus/Leaflet.GeometryUtil)使用L.GeometryUtil.closestLayer。 https://github.com/mapbox/leaflet-knn

PS:我必须回答,因为我无法发表评论。

© www.soinside.com 2019 - 2024. All rights reserved.