-
Notifications
You must be signed in to change notification settings - Fork 0
/
leaflet02-polygon.html
48 lines (37 loc) · 1.35 KB
/
leaflet02-polygon.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
<!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);
// Add a marker
L.marker([52.20203, 0.12466]).addTo(map)
.bindPopup("We're here at Novi!<br />Hi PHP Cambridge :)")
.openPopup();
// Add a polygon
var polygon = L.polygon([
[52.20170, 0.12587],
[52.20201, 0.12804],
[52.20031, 0.12777]
]).addTo(map);
polygon.bindPopup("I am a corner of Parker's Piece.");
</script>
</body>
</html>