-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
70 lines (65 loc) · 1.93 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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="leaflet/leaflet.css" />
<script src="leaflet/leaflet.js"></script>
<script src="jquery-3.3.1.min.js"></script>
<style>
#map {
height: 500px;
}
</style>
</head>
<body>
<div id="map"></div>
<script>
// create a map of NL
var map = L.map('map').setView([52.1460121, 5.9052025], 7);
// add an OpenStreetMap tile layer
L.tileLayer('http://{s}.tiles.wmflabs.org/bw-mapnik/{z}/{x}/{y}.png', {
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
// popup function
function onEachFeature(feature, layer) {
// does this feature have a property named popupContent?
if (feature.properties && feature.properties.popupContent) {
layer.bindPopup(feature.properties.popupContent);
} else if (feature.properties.name) {
var html = '<b>'+feature.properties.name+'</b><br/>'+
feature.properties.address+'<br/>'+
"<a href='"+feature.properties.url+"' target='_blank' >website</a><br/>"+
feature.properties.description;
layer.bindPopup(html);
} else{
console.log("oneachfeature");
};
}
// styling funtion
function pointToLayer(feature, latlon) {
var icon = feature.properties['marker-symbol'];
var iconurl = 'img/'+icon+'.png';
return new L.Marker(latlon, {
icon: new L.icon({
iconUrl: iconurl,
iconSize: [30, 70],
iconAnchor: [15, 35],
popupAnchor: [0, -25]
})
});
}
var geojsonURL = 'data/all.geojson';
$.ajax({
type: "GET",
url: geojsonURL,
dataType: 'json',
success: function (response) {
geojsonLayer = L.geoJson(response, {
onEachFeature: onEachFeature,
pointToLayer: pointToLayer
}).addTo(map);
}
});
</script>
</body>
</html>