javascript - 在传单 OSM 上的附近搜索
问题描述
有人可以帮我在传单上搜索附近吗?目前我只有地理编码搜索,我希望当我搜索一个地方时,我可以在一个范围内看到附近的商店、医疗中心、餐馆等。
<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: '© <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>
这是我目前拥有的代码行。
解决方案
推荐阅读
- regex - .htaccess mod_rewrite 在组为空时跳过捕获组
- python - 检查角色是否具有权限 - Discord.py
- python - __init__() 缺少 4 个必需的位置参数
- node.js - 自定义钩子是否可用于 node.js 生命周期?
- android - 在 Android 应用程序的生命周期中维护属性/值、持久化和访问它们的最佳实践?
- testing - 在测试中单击提交按钮后完成哪个过程
- docker - 通过 curl 连接 GRPC 服务?
- java - 在相关实体中找不到类的序列化程序
- c++ - 为什么 conditional_variable::notify_all 可能不会唤醒任何线程?
- scipy-optimize - 确定 scipy.optimize.curve_fit 初始猜测