mirror of
https://github.com/aljazceru/twentyone-world.github.io.git
synced 2025-12-20 08:04:26 +01:00
feat: colorize countries
WIP
This commit is contained in:
@@ -100,7 +100,8 @@
|
|||||||
"alpha3": "AUT",
|
"alpha3": "AUT",
|
||||||
"numeric": 40,
|
"numeric": 40,
|
||||||
"latitude": 47.3333,
|
"latitude": 47.3333,
|
||||||
"longitude": 13.3333
|
"longitude": 13.3333,
|
||||||
|
"link": "https://einundzwanzig.space/meetups"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"country": "Azerbaijan",
|
"country": "Azerbaijan",
|
||||||
@@ -631,7 +632,7 @@
|
|||||||
"longitude": 9,
|
"longitude": 9,
|
||||||
"city_name": "Munich",
|
"city_name": "Munich",
|
||||||
"nb_visits": 456,
|
"nb_visits": 456,
|
||||||
"href": "https://einundzwanzig.space/meetups"
|
"link": "https://einundzwanzig.space/meetups"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"country": "Ghana",
|
"country": "Ghana",
|
||||||
|
|||||||
25
index.html
25
index.html
@@ -42,7 +42,7 @@ jsplugins:
|
|||||||
fill: '#333'
|
fill: '#333'
|
||||||
},
|
},
|
||||||
mouseenter: function (d, path) {
|
mouseenter: function (d, path) {
|
||||||
path.attr('fill', Math.random() < 0.5 ? '#c04' : '#04c');
|
path.attr('fill', Math.random() < 0.5 ? '#735000' : '#BBB');
|
||||||
},
|
},
|
||||||
mouseleave: function (d, path) {
|
mouseleave: function (d, path) {
|
||||||
path.animate({ fill: '#333' }, 1000);
|
path.animate({ fill: '#333' }, 1000);
|
||||||
@@ -58,6 +58,29 @@ jsplugins:
|
|||||||
success: function (countries) {
|
success: function (countries) {
|
||||||
|
|
||||||
var scale = kartograph.scale.sqrt(countries.concat([{ nb_visits: 0 }]), 'nb_visits').range([0, 60]);
|
var scale = kartograph.scale.sqrt(countries.concat([{ nb_visits: 0 }]), 'nb_visits').range([0, 60]);
|
||||||
|
var orangeCountries = countries.filter(function hasLink(c) {
|
||||||
|
var hasLink = c.link ? true : false;
|
||||||
|
return hasLink;
|
||||||
|
});
|
||||||
|
|
||||||
|
map.getLayer('countries').style('fill', function (data) {
|
||||||
|
console.log('gnaaa');
|
||||||
|
var germany = countries[0];
|
||||||
|
console.log(germany);
|
||||||
|
|
||||||
|
|
||||||
|
console.log('ORANGE COUNTRIES: ' + orangeCountries);
|
||||||
|
var orangeCountryCodes = orangeCountries.map(function(c) {
|
||||||
|
return c.alpha3;
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log('ORANGE CODES: ' + orangeCountryCodes);
|
||||||
|
|
||||||
|
var isOrangeCountry = orangeCountryCodes.includes(data.iso)
|
||||||
|
|
||||||
|
return isOrangeCountry ? '#d00' : '#ccc';
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
map.addSymbols({
|
map.addSymbols({
|
||||||
type: kartograph.Bubble,
|
type: kartograph.Bubble,
|
||||||
|
|||||||
Reference in New Issue
Block a user