<bdo id='eA1oO'></bdo><ul id='eA1oO'></ul>
<legend id='eA1oO'><style id='eA1oO'><dir id='eA1oO'><q id='eA1oO'></q></dir></style></legend>

<small id='eA1oO'></small><noframes id='eA1oO'>

<i id='eA1oO'><tr id='eA1oO'><dt id='eA1oO'><q id='eA1oO'><span id='eA1oO'><b id='eA1oO'><form id='eA1oO'><ins id='eA1oO'></ins><ul id='eA1oO'></ul><sub id='eA1oO'></sub></form><legend id='eA1oO'></legend><bdo id='eA1oO'><pre id='eA1oO'><center id='eA1oO'></center></pre></bdo></b><th id='eA1oO'></th></span></q></dt></tr></i><div id='eA1oO'><tfoot id='eA1oO'></tfoot><dl id='eA1oO'><fieldset id='eA1oO'></fieldset></dl></div>

    1. <tfoot id='eA1oO'></tfoot>

    2. 如何找到最近的标记leaflet.js

      时间:2023-08-09
        • <bdo id='KQ6EO'></bdo><ul id='KQ6EO'></ul>

            <tbody id='KQ6EO'></tbody>
            <i id='KQ6EO'><tr id='KQ6EO'><dt id='KQ6EO'><q id='KQ6EO'><span id='KQ6EO'><b id='KQ6EO'><form id='KQ6EO'><ins id='KQ6EO'></ins><ul id='KQ6EO'></ul><sub id='KQ6EO'></sub></form><legend id='KQ6EO'></legend><bdo id='KQ6EO'><pre id='KQ6EO'><center id='KQ6EO'></center></pre></bdo></b><th id='KQ6EO'></th></span></q></dt></tr></i><div id='KQ6EO'><tfoot id='KQ6EO'></tfoot><dl id='KQ6EO'><fieldset id='KQ6EO'></fieldset></dl></div>

                <small id='KQ6EO'></small><noframes id='KQ6EO'>

              1. <legend id='KQ6EO'><style id='KQ6EO'><dir id='KQ6EO'><q id='KQ6EO'></q></dir></style></legend>
                <tfoot id='KQ6EO'></tfoot>

                本文介绍了如何找到最近的标记leaflet.js的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我想知道是否真的有某种方法可以使用 Leaflet.js 在我的位置附近找到标记.我想到的第一个想法是存储我的位置的 lat 和 lng,然后遍历一组 lat 和 lng 标记,将它们放在一个数组中,然后对该数组进行排序.我不确定这是否是一个不错的选择,因为如果您在地图上有一百万个标记需要一段时间.

                I was wondering if there is actually some way to find markers near my position using leaflet.js. The first think to come to my head is to store lat and lng of my position and then iterate over an array of lat and lng markers placing them in an array an then sort that array. I am not sure if this is a good option because if you have a million markers in the map is going to take a while.

                伪代码

                var myLatLng = [34,56];
                var markers = [[20,30],[10,20],[12,-100],[54,90],[-10, -20],[20,20]];
                var closests = [];
                function findNearestMarker (myPosition, nearestMarkers){
                 for(var i = 0; i < nearestMarkers.length){
                     if((nearestMarkers[i][0] - myPosition[0]) < 100 && (nearestMarkers[i][1] - myPosition[1]) < 100 ){
                         closests.push(nearestMarkers[i])
                     }
                 }
                }
                

                我实际上是从地图开始,不知道这么多方法,我也想在这个项目中使用开放的街道地图,但是,如果有人知道并使用谷歌地图或其他服务,我将受到欢迎.

                I am actually starting with maps and dont know so many approaches, I will also like to use open street maps for this project, but, if someone know and aproach using google maps or another services it will be welcomed.

                推荐答案

                试试leaflet-knn,它进行最近邻查找:给定一个点和一堆其他点,它会找到最近的邻居(正如它在锡上所说的那样)

                Try leaflet-knn, which does nearest-neighbor lookups: given a point and a bunch of other points, it finds the nearest neighbors (as it says on the tin)

                这篇关于如何找到最近的标记leaflet.js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:使用 Leaflet.js 和 OSM 时仅显示美国 下一篇:传单只加载一个瓷砖

                相关文章

                最新文章

                <legend id='LFpyO'><style id='LFpyO'><dir id='LFpyO'><q id='LFpyO'></q></dir></style></legend>

                    <bdo id='LFpyO'></bdo><ul id='LFpyO'></ul>
                  <i id='LFpyO'><tr id='LFpyO'><dt id='LFpyO'><q id='LFpyO'><span id='LFpyO'><b id='LFpyO'><form id='LFpyO'><ins id='LFpyO'></ins><ul id='LFpyO'></ul><sub id='LFpyO'></sub></form><legend id='LFpyO'></legend><bdo id='LFpyO'><pre id='LFpyO'><center id='LFpyO'></center></pre></bdo></b><th id='LFpyO'></th></span></q></dt></tr></i><div id='LFpyO'><tfoot id='LFpyO'></tfoot><dl id='LFpyO'><fieldset id='LFpyO'></fieldset></dl></div>
                  1. <small id='LFpyO'></small><noframes id='LFpyO'>

                    <tfoot id='LFpyO'></tfoot>