-
Notifications
You must be signed in to change notification settings - Fork 0
/
leaflet05-addgeojson.html
69 lines (57 loc) · 1.8 KB
/
leaflet05-addgeojson.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
<!DOCTYPE html>
<html>
<head>
<title>Map</title>
<!-- Load Leaflet.js and styles from a CDN -->
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" />
<style type="text/css">
#map {width: 100%; height: 600px;}
</style>
</head>
<body>
<!-- The div where the map goes -->
<div id="map"></div>
<!-- Map javascript -->
<script type="text/javascript">
// Create a map
var map = L.map('map')
.setView([52.2015, 0.127], 17); // Easy way to work out lat/lon/zoom is http://www.openstreetmap.org/
// Add tile background
L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© <a href="https://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
// Load GeoJSON from file
var geojsonData = {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [0.12484, 52.202]
}
},
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[0.12590, 52.20172],
[0.127683, 52.20055],
[0.127876, 52.20194],
[0.125902, 52.20172]
]
]
}
}
]
}
// Add the GeoJSON to the map
L.geoJSON(geojsonData).addTo(map);
</script>
</body>
</html>