forked from obisargoni/GH_WebMap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
84 lines (71 loc) · 3.41 KB
/
index.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
<!DOCTYPE html>
<html>
<head>
<title>Simple (Halloween) Map with some locations</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" type="image/x-icon" href="docs/images/favicon.ico" />
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.5.1/dist/leaflet.css" integrity="sha512-xwE/Az9zrjBIphAcBb3F6JVqxf46+CDLwfLMHloNu6KEQCAWi6HcDUbeOfBIptF7tcCzusKFjFw2yuvEpDL9wQ==" crossorigin=""/>
<!-- leaflet-->
<script src="https://unpkg.com/leaflet@1.5.1/dist/leaflet.js" integrity="sha512-GffPMF3RvMeYyc1LWMHtK8EbPv0iNZ8/oTtHPx9/cc2ILxQ+u905qIwdpULaqDkyBKgOaB57QTMg7ztg8Jm2Og==" crossorigin=""></script>
<!--jQuery-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!-- Just a csv parser https://www.papaparse.com/ -->
<script src="js/papaparse.min.js"></script>
</head>
<body>
<div id="mapid" style="width: 1500px; height: 900px;"></div>
<script>
var mymap = L.map('mapid').setView([51.505, -0.09], 7); //Initialise the leaflet map in our div
//this is an error;
// Other Tile Map Style can be found here : http://leaflet-extras.github.io/leaflet-providers/preview/index.html
//NEVER expose an apikey!!
//https://help.github.com/en/github/authenticating-to-github/removing-sensitive-data-from-a-repository /Remove a file from history
//https://gist.github.com/derzorngottes/3b57edc1f996dddcab25 /gitIgnore
L.tileLayer(
'https://tile.thunderforest.com/spinal-map/{z}/{x}/{y}.png?apikey=db40e05369694ca8ac66856aa8d3b1a9', //thunderforest Layer
//'https://tile.thunderforest.com/transport/{z}/{x}/{y}.png?apikey=db40e05369694ca8ac66856aa8d3b1a9', //thunderforest Layer
//'https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}{r}.png', //CARTO DB Layer
{
maxZoom: 18,
attribution: '© <a href="http://www.thunderforest.com/">Thunderforest</a>, © <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors', //Thunderforest Attribution
//attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors © <a href="https://carto.com/attributions">CARTO</a>', //CARTO attribution
}).addTo(mymap);
var pumpkinIcon = new L.Icon({
iconUrl: 'img/pumpkin_pl_SHD.png',
iconSize: [50, 50],
iconAnchor: [12, 41],
popupAnchor: [1, -34],
});
//Add locations using CSV DATA
for(var k=0;k<35;k++) //bad loop, but for the workshop is ok
{// CSV need to be place in the locations folder and named locationsX.csv where X is the number
Papa.parse("./locations/locations"+k+".csv",
{
download: true,
complete: function(results,file) {
results.data.forEach(element => {
console.log(element[3]);
var marker = L.marker([element[0], element[1]],{icon:pumpkinIcon}).addTo(mymap);
marker.bindPopup("<b>"+element[2]+"</b><br>"+element[3]
+"</b><br>"+element[4]).openPopup();
});
}
});
}
//END CSV
//Using JSON
/*
$.getJSON("locationJson/location.json", function(json_location) {
console.log(json_location.features.length);
json_location.features.forEach(function(placeToMap)
{
var marker = L.marker([placeToMap.geometry.coordinates[1],placeToMap.geometry.coordinates[0]],{icon:pumpkinIcon}).addTo(mymap);
marker.bindPopup("<b>"+placeToMap.name+"</b><br>"+placeToMap.properties.place).openPopup();
})
}
)
*/
</script>
</body>
</html>