-
Notifications
You must be signed in to change notification settings - Fork 64
/
costumMarkerImage.html
96 lines (83 loc) · 2.3 KB
/
costumMarkerImage.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
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<title></title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.53.1/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.53.1/mapbox-gl.css' rel='stylesheet' />
<style>
body {
margin: 0;
padding: 0;
background-color: #000;
color: #fff;
}
#map {
position: absolute;
height: 600px;
width: 100%;
}
</style>
</head>
<body>
<div id='map'></div>
<script>
mapboxgl.accessToken = 'YOUR-TOKEN-HERE';
var map = new mapboxgl.Map({
container: 'map',
style: 'YOUR-STYLE-URL-HERE',
center: [9.74, 55.05],
zoom: 10
});
// code from the next step will go here!
let geojson = {
"features": [{
"type": "Feature",
"properties": {
"city": "Nordborg",
"symbol": "tux.png" // add a picture to the image folder
},
"geometry": {
"coordinates": [
9.742207,
55.054442
],
"type": "Point"
},
"id": "47dfbd93a4ac0e3d94d492fc6fe5f0cb"
},
{
"type": "Feature",
"properties": {
"city": "Augustenborg",
"symbol": "tux2.png" // add a picture to the image folder
},
"geometry": {
"coordinates": [
9.877219,
54.946994
],
"type": "Point"
},
"id": "9bec41b72adf6c7e74b090764c46fcc2"
}
],
"type": "FeatureCollection"
}
for (i = 0; i < geojson.features.length; i++) {
// create html element in the DOM
var el = document.createElement('img');
el.src = 'images/' + geojson.features[i].properties.symbol;
el.alt = geojson.features[i].properties.city;
el.style = 'width: 75px;height:auto;';
// add the markers to the map
new mapboxgl.Marker(el)
.setLngLat(geojson.features[i].geometry.coordinates)
.addTo(map);
// by thine own ingenium add a popup with text
}
</script>
</body>
</html>