-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathviewer.maplibre.html
More file actions
37 lines (36 loc) · 1.39 KB
/
viewer.maplibre.html
File metadata and controls
37 lines (36 loc) · 1.39 KB
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
29
30
31
32
33
34
35
36
37
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" />
<title>Bharat Address Viewer (Demo)</title>
<link href="https://unpkg.com/maplibre-gl@3.6.1/dist/maplibre-gl.css" rel="stylesheet" />
<style>body,html,#map{margin:0;height:100%} .marker{background:#e74c3c;border-radius:50%;width:8px;height:8px}</style>
</head>
<body>
<div id="map"></div>
<script src="https://unpkg.com/maplibre-gl@3.6.1/dist/maplibre-gl.js"></script>
<script>
// Replace this basemap with a permitted NIC WMTS in government contexts.
const map = new maplibregl.Map({
container: 'map',
style: 'https://demotiles.maplibre.org/style.json',
center: [77.6, 12.97],
zoom: 12
});
async function loadAddresses() {
const url = 'http://localhost:8000/collections/addresses/items?limit=100';
const resp = await fetch(url);
const data = await resp.json();
map.on('load', () => {
map.addSource('addresses', { type: 'geojson', data });
map.addLayer({
id: 'addresses', type: 'circle', source: 'addresses',
paint: { 'circle-radius': 4, 'circle-color': '#e74c3c', 'circle-stroke-width': 1, 'circle-stroke-color': '#fff' }
});
});
}
loadAddresses();
</script>
</body>
</html>