-
Notifications
You must be signed in to change notification settings - Fork 0
/
main2.js
28 lines (27 loc) · 835 Bytes
/
main2.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { map, currentMarkers } from "./main";
const apiKey = "YOUR_API_KEY";
import { geocode } from "esri-leaflet-geocoder";
export function showPlaces() {
let position;
geocode({
apikey: apiKey,
})
.category("Post Office")
.nearby(map.getCenter(), 1)
.run(function(err, response) {
for (const result of response.results) {
position = new L.LatLng(result.latlng.lat, result.latlng.lng);
currentMarkers.push(
new L.marker(position).addTo(map).bindTooltip(() => {
return L.Util.template(
`<b>${result.properties.PlaceName}</b><br/>
${result.properties.Place_addr}<br/>
${result.properties.Phone}<br/>
${result.properties.URL}`
);
})
);
}
});
map.setView(position, 14);
}