-
Notifications
You must be signed in to change notification settings - Fork 1
/
Lab_4.41.html
144 lines (132 loc) · 4.25 KB
/
Lab_4.41.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
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<title>Add custom icons with Markers</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v1.6.0/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v1.6.0/mapbox-gl.css' rel='stylesheet' />
<style>
body { margin: 0; padding: 0; }
#map { position: absolute; top: 0; bottom: 0; width: 100%; };
</style>
</head>
<body>
<style>
.marker {
display: block;
border: none;
border-radius: 50%;
cursor: pointer;
padding: 0;
}
</style>
<div id='map'></div>
<script src="js/cats.js"></script>
<script>
// In past labs, I've loaded json data through a function...? Can this be done here?
// mapOne.addSource('earthquakes', {
// "type": "geojson",
// "data": "https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/2.5_week.geojson"
// });
// var geojson = {
// type: 'geojson',
// data: 'geoJSON/cats.json'
// "type": "FeatureCollection",
// "features": [
// {
// "type": "Feature",
// "properties": {
// "message": "Foo",
// "iconSize": [60, 60]
// },
// "geometry": {
// "type": "Point",
// "coordinates": [
// -66.324462890625,
// -16.024695711685304
// ]
// }
// },
// {
// "type": "Feature",
// "properties": {
// "message": "Bar",
// "iconSize": [50, 50]
// },
// "geometry": {
// "type": "Point",
// "coordinates": [
// -61.2158203125,
// -15.97189158092897
// ]
// }
// },
// {
// "type": "Feature",
// "properties": {
// "message": "Baz",
// "iconSize": [40, 40]
// },
// "geometry": {
// "type": "Point",
// "coordinates": [
// -63.29223632812499,
// -18.28151823530889
// ]
// }
// }
// ]
// };
// Add custom markers in Mapbox GL JS: https://docs.mapbox.com/help/tutorials/custom-markers-gl-js/
// Add custom icons with Markers: https://docs.mapbox.com/mapbox-gl-js/example/custom-marker-icons/
// add markers to map
// geojson.features.forEach(function(marker) {
// // create a DOM element for the marker
// var el = document.createElement('div');
// el.className = 'marker';
// el.style.backgroundImage = 'url(img/icons/' + marker.properties.iconSize.join('/') + '/)';
// el.style.width = marker.properties.iconSize[0] + 'px';
// el.style.height = marker.properties.iconSize[1] + 'px';
//
// el.addEventListener('click', function() {
// window.alert(marker.properties.message);
// });
//
// // add marker to map
// new mapboxgl.Marker(el)
// .setLngLat(marker.geometry.coordinates)
// .addTo(map);
// OR Could I Create layer and match property from source using icon: https://docs.mapbox.com/mapbox-gl-js/example/data-join/
//
// map.addSource("states", { //"units"?
// type: "vector", //type: "geojson",?
// url: "mapbox://mapbox.us_census_states_2015" // "geoJSON/battleOfTheBulge.json"?
// });
//
// var expression = ["match", ["get", "STATE_ID"]]; //"SymbolID"?
//
// // Calculate color for each state based on the unemployment rate
// data.forEach(function(row) {
// var green = (row["unemployment"] / maxValue) * 255;
// var color = "rgba(" + 0 + ", " + green + ", " + 0 + ", 1)"; ? //var icon?
// expression.push(row["STATE_ID"], color); //["SymbolID"], icon);?
// });
//
// // Last value is the default, used where there is no data
// expression.push("rgba(0,0,0,0)"); //Image URL?
//
// // Add layer from the vector tile source with data-driven style
// map.addLayer({
// "id": "states-join", //??
// "type": "fill", //symbol?
// "source": "states", //"units"?
// "source-layer": "states",//"units"?
// "paint": { //layout?
// "fill-color": expression //icon-image?
// }
// }, 'waterway-label');
// });
</script>
</body>
</html>