Created
April 12, 2020 20:36
-
-
Save wmerrow/f079f7eea2931bb225891c18fa4cc707 to your computer and use it in GitHub Desktop.
class 9 assignment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<title>Will's class 9 assignment</title> | |
<script src='https://api.mapbox.com/mapbox-gl-js/v1.8.1/mapbox-gl.js'></script> | |
<link rel="stylesheet" type="text/css" href="style.css"> | |
<link href='https://api.mapbox.com/mapbox-gl-js/v1.8.1/mapbox-gl.css' rel='stylesheet' /> | |
<script>mapboxgl.accessToken = 'pk.eyJ1Ijoid21lcnJvdyIsImEiOiJjazh3ZHIyemUwbTNsM2Zta2kwYTZ1eGQyIn0.wbyABgPyAjSzaqC8bBgUUw';</script> | |
</head> | |
<body> | |
<div id='map'></div> | |
<div class='map-overlay' id='features'><h2>Renting in Sunset Park</h2><div id='pd'><p>Share of residents who rent, 2013-2017</p></div></div> | |
<div class='map-overlay' id='legend'></div> | |
</body> | |
<script> | |
var map = new mapboxgl.Map({ | |
container: 'map', // container id | |
style: 'mapbox://styles/wmerrow/ck8x8qrwd2j1z1io6fbyi9xup' // replace this with your style URL | |
}); | |
map.on('load', function() { | |
// the rest of the code will go in here | |
var layers = ['38.42-49.78%', '49.78-61.13%', '61.13-72.49%', '72.49-83.85%', '83.85-95.20%'] | |
var colors = ['#fff6d7', '#efcba1', '#df9f6b', '#cf7435', '#be4900']; | |
for (i = 0; i < layers.length; i++) { | |
var layer = layers[i]; | |
var color = colors[i]; | |
var item = document.createElement('div'); | |
var key = document.createElement('span'); | |
key.className = 'legend-key'; | |
key.style.backgroundColor = color; | |
var value = document.createElement('span'); | |
value.innerHTML = layer; | |
item.appendChild(key); | |
item.appendChild(value); | |
legend.appendChild(item); | |
} | |
}); | |
</script> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
margin: 0; | |
padding: 0; | |
} | |
h2, | |
h3 { | |
margin: 10px; | |
font-size: 1.2em; | |
} | |
h3 { | |
font-size: 1em; | |
} | |
p { | |
font-size: 0.85em; | |
margin: 10px; | |
text-align: left; | |
} | |
/** | |
* Create a position for the map | |
* on the page */ | |
#map { | |
position: absolute; | |
top: 0; | |
bottom: 0; | |
width: 100%; | |
} | |
/** | |
* Set rules for how the map overlays | |
* (information box and legend) will be displayed | |
* on the page. */ | |
.map-overlay { | |
position: absolute; | |
bottom: 0; | |
right: 0; | |
background: rgba(255, 255, 255, 0.8); | |
margin-right: 20px; | |
font-family: Arial, sans-serif; | |
overflow: auto; | |
border-radius: 3px; | |
} | |
#features { | |
top: 0; | |
height: 80px; | |
margin-top: 20px; | |
width: 275px; | |
} | |
#legend { | |
padding: 10px; | |
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1); | |
line-height: 18px; | |
height: 100px; | |
margin-bottom: 40px; | |
width: 120px; | |
} | |
.legend-key { | |
display: inline-block; | |
border-radius: 20%; | |
width: 10px; | |
height: 10px; | |
margin-right: 5px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment