-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmapboxgl-symbology.html
148 lines (136 loc) · 3.15 KB
/
mapboxgl-symbology.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<title></title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.12.2/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.12.2/mapbox-gl.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
#map { position:absolute; top:0; bottom:0; width:100%; }
</style>
</head>
<body>
<div id='map'></div>
<script>
mapboxgl.accessToken = 'pk.eyJ1IjoiamFja2RvdWdoZXJ0eSIsImEiOiJxMi11TGlzIn0.ydUTGpMKcADi7fKPxy0GVA';
var randomPoints = {
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"properties": {
"marker-symbol": "monument"
},
"geometry": {
"type": "Point",
"coordinates": [-72.69, 41.76]
}
}, {
"type": "Feature",
"properties": {
"marker-symbol": "bar"
},
"geometry": {
"type": "Point",
"coordinates": [-72.71, 41.755]
}
}, {
"type": "Feature",
"properties": {
"marker-symbol": "bus"
},
"geometry": {
"type": "Point",
"coordinates": [-72.70, 41.745]
}
}]
};
var locations = {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"id": "Ann Street"
},
"geometry": {
"type": "Point",
"coordinates": [
-72.6782,
41.7676
]
}
},
{
"type": "Feature",
"properties": {
"id": "Hopkins Street"
},
"geometry": {
"type": "Point",
"coordinates": [
-72.6848,
41.7677
]
}
},
{
"type": "Feature",
"properties": {
"id": "Forest Street"
},
"geometry": {
"type": "Point",
"coordinates": [
-72.701,
41.7652
]
}
}
]
};
var map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/mapbox/streets-v8',
center: [-72.67, 41.76],
zoom: 12.5
});
map.on('style.load', function () {
// Add point markers as new geoJson source from in-line code above
map.addSource("markers1", {
"type": "geojson",
"data": randomPoints
});
// Add a layer showing the point markers
map.addLayer({
"id": "markers1",
"source": "markers1",
// "interactive": true,
"type": "symbol",
"layout": {
"icon-image": "{marker-symbol}-15"
}
});
}); // end of function
map.on('style.load', function () {
// Add circles as new geoJson source from in-line code above
map.addSource("markers2", {
"type": "geojson",
"data": locations
});
// Add a layer showing the circles
map.addLayer({
"id": "markers2",
"source": "markers2",
"type": "circle",
"paint": {
"circle-radius": 8,
"circle-color": "#000099",
"circle-opacity": 0.7
}
});
}); // end of function
</script>
</body>
</html>