Polish project 2 aufgabe 1
This commit is contained in:
parent
5ddad82db2
commit
ca151488ac
@ -54,41 +54,41 @@
|
||||
integrity="sha512-XQoYMqMTK8LvdxXYG3nZ448hOEQiglfqkJs1NOQV44cWnUrBc8PkAOcXy20w0vlaXaVUearIOBhiXZ5V3ynxwA=="
|
||||
src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js"></script>
|
||||
<script>
|
||||
const map = L.map('map').setView([53.0, 14.0], 4)
|
||||
const levels = [
|
||||
1_000_000, 5_000_000, 10_000_000, 20_000_000,
|
||||
30_000_000, 50_000_000, 80_000_000, 100_000_000
|
||||
]
|
||||
let geojson;
|
||||
|
||||
const getColor = population => {
|
||||
switch (true) {
|
||||
case population > 100_000_000:
|
||||
case population > levels[7]:
|
||||
return {color: '#800026', name: '100 Mio'}
|
||||
case population > 80_000_000:
|
||||
case population > levels[6]:
|
||||
return {color: '#BD0026', name: '80 Mio'}
|
||||
case population > 50_000_000:
|
||||
case population > levels[5]:
|
||||
return {color: '#E31A1C', name: '50 Mio'}
|
||||
case population > 30_000_000:
|
||||
case population > levels[4]:
|
||||
return {color: '#FC4E2A', name: '30 Mio'}
|
||||
case population > 20_000_000:
|
||||
case population > levels[3]:
|
||||
return {color: '#FD8D3C', name: '20 Mio'}
|
||||
case population > 10_000_000:
|
||||
case population > levels[2]:
|
||||
return {color: '#FEB24C', name: '10 Mio'}
|
||||
case population > 5_000_000:
|
||||
case population > levels[1]:
|
||||
return {color: '#FED976', name: '5 Mio'}
|
||||
case population > 1_000_000:
|
||||
case population > levels[0]:
|
||||
return {color: '#ffdb83', name: '1 Mio'}
|
||||
default:
|
||||
return {color: '#ffdea1', name: ''}
|
||||
}
|
||||
}
|
||||
|
||||
let map = L.map('map').setView([53.0, 14.0], 4)
|
||||
let geojson;
|
||||
|
||||
// Add the legend to the map
|
||||
const legend = L.control({position: 'bottomright'})
|
||||
|
||||
legend.onAdd = () => {
|
||||
const legend = L.DomUtil.create('div', 'info legend')
|
||||
const levels = [
|
||||
1_000_000, 5_000_000, 10_000_000, 20_000_000,
|
||||
30_000_000, 50_000_000, 80_000_000, 100_000_000
|
||||
]
|
||||
const labels = []
|
||||
|
||||
for (let i = 0; i < levels.length; i++) {
|
||||
@ -164,7 +164,6 @@
|
||||
$.getJSON('europe.geo.json', data => {
|
||||
geojson = L.geoJson(data, {style: getStyle, onEachFeature}).addTo(map)
|
||||
})
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user