This repository has been archived by the owner on Dec 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmap.html
105 lines (81 loc) · 2.87 KB
/
map.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<!DOCTYPE html>
<html>
<head>
<title>Mapbox-style map for the map of effective altruists</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css" />
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/leaflet.markercluster/0.4.0/MarkerCluster.Default.css" />
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/leaflet.markercluster/0.4.0/MarkerCluster.css" />
</head>
<body>
<script src="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/leaflet.markercluster/0.4.0/leaflet.markercluster.js"></script>
<div id="map" style="
position: relative;
margin: 2em auto;
width: 480px;
height: 280px
"></div>
<script>
//<![CDATA[
window.markerData = [
/* example of script output: */
{"latlng":[49.261226,-123.1139268],"popup":"<a href=\"\/users\/21\">John Doe<\/a>","icon":"user"}
,
{"latlng":[41.3065186,-72.9310714],"popup":"<a href=\"\/users\/61\">Overlapping person 1<\/a>","icon":"user"}
,
{"latlng":[41.3065186,-72.9310714],"popup":"<a href=\"\/users\/61\">Overlapping person 1<\/a>","icon":"user"}
];
//]]>
</script>
<script>
var map = L.map('map', {
center: [5, 5],
zoom: 1
/* VARIANT SETTINGS
==Small map==
center: [5, 5],
zoom: 1
// with html:
<div id="map" style="
position: relative;
margin: 2em auto;
width: 480px;
height: 280px
"></div>
============
==Large map==
center: [25,7],
zoom: 2
// with html:
<!-- Map HTML - 1000px fits world neater, but is wider than the current 940px width of the EA Hub theme -->
<div id="map" style="
position: relative;
margin: 4em auto;
max-width: 1000px;
width: 940px;
height: 570px;
"></div>
*/
});
L.tileLayer('https://{s}.tiles.mapbox.com/v3/{id}/{z}/{x}/{y}.png', {
maxZoom: 18,
attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' +
'<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' +
'Imagery © <a href="http://mapbox.com">Mapbox</a>',
id: 'examples.map-i875mjb7'
}).addTo(map);
var markerData = window.markerData;
var markers = new L.MarkerClusterGroup();
for(var i = 0; i < markerData.length; i++) {
var currentMarkerData = markerData[i];
var latlng = currentMarkerData.latlng;
var popup = currentMarkerData.popup;
var marker = new L.marker(latlng).bindPopup(popup);
markers.addLayer(marker);
}
map.addLayer(markers);
</script>
</body>
</html>