-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBase layers and overlays.html
82 lines (68 loc) · 2.23 KB
/
Base layers and overlays.html
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- leaflet -->
<title>Base layers and overlays</title>
</head>
<style>
#map {
height: 100vh;
width: 100%;
}
</style>
<body>
<div id="map"></div>
</body>
</html>
<script>
var map = L.map('map').setView([28, 84], 6);
//adding tilelayers for base maps
var osm = L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 20,
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
}).addTo(map);
var Esri_WorldImagery = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {
maxZoom: 20,
});
var OpenTopoMap = L.tileLayer('https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png', {
maxZoom: 20,
});
//creating layergroup for Geojson data set
var district = L.layerGroup();
var headquarter = L.layerGroup();
var earthquake = L.layerGroup();
//fetch of the geojson files
fetch('src/nepal-districts-new.geojson')
.then(response => response.json())
.then(data => {
L.geoJSON(data).addTo(district);
});
fetch('src/nepal-district-headquarters.geojson')
.then(response => response.json())
.then(data => {
L.geoJSON(data).addTo(headquarter);
});
fetch('src/Earthquake 2015.geojson')
.then(response => response.json())
.then(data => {
L.geoJSON(data).addTo(earthquake);
});
//base maps
var baseMaps = {
"OpenStreetMap": osm,
"World Imagery": Esri_WorldImagery,
"Open Topographic Map": OpenTopoMap
};
//overlay maps
var overlayMaps = {
"Districts": district,
"District Headquarters": headquarter,
"Nepal-Earthquake 2015": earthquake
};
//layercontrol for base maps and overlay maps
var layerControl = L.control.layers(baseMaps, overlayMaps).addTo(map);
</script>