在传单OSM上附近搜索

时间:2019-04-25 21:07:22

标签: javascript html leaflet

有人可以帮助我在传单上进行附近搜索吗?目前,我只进行地理编码搜索,我希望当我搜索某个地点时,可以看到一定范围内附近的商店,医疗中心,餐馆等。

<link rel="stylesheet" href="https://unpkg.com/leaflet@1.4.0/dist/leaflet.css"
    integrity="sha512-puBpdR0798OZvTTbP4A8Ix/l+A4dHDD0DGqYW6RQ+9jxkRFclaxxQb/SJAWZfWAkuyeQUytO7+7N4QKrDh+drA=="
    crossorigin=""/>
  <script src="https://unpkg.com/leaflet@1.4.0/dist/leaflet.js"
    integrity="sha512-QVftwZFqvtRNi0ZyCtsznlKSWOStnDORoefr1enyq5mVL4tmKB3S/EnC3rRJcxCPavG10IcrVGSmPh6Qw5lwrg=="
    crossorigin=""></script>

<!-- Load Esri Leaflet from CDN -->
  <script src="https://unpkg.com/esri-leaflet@2.2.4/dist/esri-leaflet.js"
    integrity="sha512-tyPum7h2h36X52O2gz+Pe8z/3l+Y9S1yEUscbVs5r5aEY5dFmP1WWRY/WLLElnFHa+k1JBQZSCDGwEAnm2IxAQ=="
    crossorigin=""></script>

<!-- Load Esri Leaflet Geocoder from CDN -->
  <link rel="stylesheet" href="https://unpkg.com/esri-leaflet-geocoder@2.2.14/dist/esri-leaflet-geocoder.css"
    integrity="sha512-v5YmWLm8KqAAmg5808pETiccEohtt8rPVMGQ1jA6jqkWVydV5Cuz3nJ9fQ7ittSxvuqsvI9RSGfVoKPaAJZ/AQ=="
    crossorigin="">
  <script src="https://unpkg.com/esri-leaflet-geocoder@2.2.14/dist/esri-leaflet-geocoder.js"
    integrity="sha512-uK5jVwR81KVTGe8KpJa1QIN4n60TsSV8+DPbL5wWlYQvb0/nYNgSOg9dZG6ViQhwx/gaMszuWllTemL+K+IXjg=="
    crossorigin=""></script>
       <style>
       #mapid{
           width: 100%;
           height: 400px;
       }
       </style>
<body>
  <div id="wrapper">
    <% include ../.././partials/nav.ejs %>
    <ul class="breadcrumb">
      <li><a href="#">Home</a></li>
      <li class="active">Dashboard</li>
    </ul>
    <div id="mapid"></div>
   <script>
   var mymap = L.map('mapid').setView([37.0902, -95.7129], 4);
   L.tileLayer('https://tiles.wmflabs.org/hikebike/{z}/{x}/{y}.png', {
    maxZoom: 19,
    attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
}).addTo(mymap);

  var searchControl = L.esri.Geocoding.geosearch().addTo(mymap);
  var results = L.layerGroup().addTo(mymap);

  searchControl.on('results', function(data){
  results.clearLayers();

  for(var i =data.results.length -1; i>=0; i--){
    results.addLayer(L.marker(data.results[i].latlng));
  }
})
  </script>

这是我当前拥有的代码行。

0 个答案:

没有答案