Skip to content

Instantly share code, notes, and snippets.

@arthurwelle
Last active July 27, 2017 02:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arthurwelle/33164717a220e6623b56367ad09d13bf to your computer and use it in GitHub Desktop.
Save arthurwelle/33164717a220e6623b56367ad09d13bf to your computer and use it in GitHub Desktop.
mapa mundi
license: mit
id name texto
-1 Northern Cyprus a
-2 Kosovo b
-3 Somaliland dee
4 Afghanistan rf
8 Albania fer
10 Antarctica frf
12 Algeria erf
16 American Samoa greghr
20 Andorra gerg
24 Angola yer
28 Antigua and Barbuda gtgtt
31 Azerbaijan frgr
32 Argentina g
36 Australia eyuhy
40 Austria De acordo c
44 Bahamas a
48 Bahrain b
50 Bangladesh dee
51 Armenia rf
52 Barbados fer
56 Belgium frf
60 Bermuda erf
64 Bhutan greghr
68 Bolivia, Plurinational State of gerg
70 Bosnia and Herzegovina yer
72 Botswana gtgtt
74 Bouvet Island frgr
76 Brazil g
84 Belize eyuhy
86 British Indian Ocean Territory greghr
90 Solomon Islands a
92 Virgin Islands, British b
96 Brunei Darussalam dee
100 Bulgaria rf
104 Myanmar fer
108 Burundi frf
112 Belarus erf
116 Cambodia greghr
120 Cameroon gerg
124 Canada yer
132 Cape Verde gtgtt
136 Cayman Islands frgr
140 Central African Republic g
144 Sri Lanka eyuhy
148 Chad greghr
152 Chile a
156 China b
158 Taiwan, Province of China dee
162 Christmas Island rf
166 Cocos (Keeling) Islands fer
170 Colombia frf
174 Comoros erf
175 Mayotte greghr
178 Congo gerg
180 Congo, the Democratic Republic of the yer
184 Cook Islands gtgtt
188 Costa Rica frgr
191 Croatia g
192 Cuba eyuhy
196 Cyprus greghr
203 Czech Republic a
204 Benin b
208 Denmark dee
212 Dominica rf
214 Dominican Republic fer
218 Ecuador frf
222 El Salvador erf
226 Equatorial Guinea greghr
231 Ethiopia gerg
232 Eritrea yer
233 Estonia gtgtt
234 Faroe Islands frgr
238 Falkland Islands (Malvinas) g
239 South Georgia and the South Sandwich Islands eyuhy
242 Fiji greghr
246 Finland a
248 Aland Islands b
250 France dee
254 French Guiana rf
258 French Polynesia fer
260 French Southern Territories frf
262 Djibouti erf
266 Gabon greghr
268 Georgia gerg
270 Gambia yer
275 Palestinian Territory, Occupied gtgtt
276 Germany frgr
288 Ghana g
292 Gibraltar eyuhy
296 Kiribati greghr
300 Greece a
304 Greenland b
308 Grenada dee
312 Guadeloupe rf
316 Guam fer
320 Guatemala frf
324 Guinea erf
328 Guyana greghr
332 Haiti gerg
334 Heard Island and McDonald Islands yer
336 Holy See (Vatican City State) gtgtt
340 Honduras frgr
344 Hong Kong g
348 Hungary eyuhy
352 Iceland greghr
356 India a
360 Indonesia b
364 Iran, Islamic Republic of dee
368 Iraq rf
372 Ireland fer
376 Israel frf
380 Italy erf
384 Cote d'Ivoire greghr
388 Jamaica gerg
392 Japan yer
398 Kazakhstan gtgtt
400 Jordan frgr
404 Kenya g
408 Korea, Democratic People's Republic of eyuhy
410 Korea, Republic of greghr
414 Kuwait a
417 Kyrgyzstan b
418 Lao People's Democratic Republic dee
422 Lebanon rf
426 Lesotho fer
428 Latvia frf
430 Liberia erf
434 Libya greghr
438 Liechtenstein gerg
440 Lithuania yer
442 Luxembourg gtgtt
446 Macao frgr
450 Madagascar g
454 Malawi eyuhy
458 Malaysia greghr
462 Maldives a
466 Mali b
470 Malta dee
474 Martinique rf
478 Mauritania fer
480 Mauritius frf
484 Mexico erf
492 Monaco greghr
496 Mongolia gerg
498 Moldova, Republic of yer
499 Montenegro gtgtt
500 Montserrat frgr
504 Morocco g
508 Mozambique eyuhy
512 Oman greghr
516 Namibia a
520 Nauru b
524 Nepal dee
528 Netherlands rf
531 Curacao fer
533 Aruba frf
534 Sint Maarten (Dutch part) erf
535 Bonaire, Sint Eustatius and Saba greghr
540 New Caledonia gerg
548 Vanuatu yer
554 New Zealand gtgtt
558 Nicaragua frgr
562 Niger g
566 Nigeria eyuhy
570 Niue greghr
574 Norfolk Island a
578 Norway b
580 Northern Mariana Islands dee
581 United States Minor Outlying Islands rf
583 Micronesia, Federated States of fer
584 Marshall Islands frf
585 Palau erf
586 Pakistan greghr
591 Panama gerg
598 Papua New Guinea yer
600 Paraguay gtgtt
604 Peru frgr
608 Philippines g
612 Pitcairn eyuhy
616 Poland greghr
620 Portugal a
624 Guinea-Bissau b
626 Timor-Leste dee
630 Puerto Rico rf
634 Qatar fer
638 Reunion frf
642 Romania erf
643 Russian Federation greghr
646 Rwanda gerg
652 Saint Barthelemy yer
654 Saint Helena, Ascension and Tristan da Cunha gtgtt
659 Saint Kitts and Nevis frgr
660 Anguilla g
662 Saint Lucia eyuhy
663 Saint Martin (French part) greghr
666 Saint Pierre and Miquelon a
670 Saint Vincent and the Grenadines b
674 San Marino dee
678 Sao Tome and Principe rf
682 Saudi Arabia fer
686 Senegal frf
688 Serbia erf
690 Seychelles greghr
694 Sierra Leone gerg
702 Singapore yer
703 Slovakia gtgtt
704 Viet Nam frgr
705 Slovenia g
706 Somalia eyuhy
710 South Africa greghr
716 Zimbabwe a
724 Spain b
728 South Sudan dee
729 Sudan rf
732 Western Sahara fer
740 Suriname frf
744 Svalbard and Jan Mayen erf
748 Swaziland greghr
752 Sweden gerg
756 Switzerland yer
760 Syrian Arab Republic gtgtt
762 Tajikistan frgr
764 Thailand g
768 Togo eyuhy
772 Tokelau greghr
776 Tonga a
780 Trinidad and Tobago b
784 United Arab Emirates dee
788 Tunisia rf
792 Turkey fer
795 Turkmenistan frf
796 Turks and Caicos Islands erf
798 Tuvalu greghr
800 Uganda gerg
804 Ukraine yer
807 Macedonia, the former Yugoslav Republic of gtgtt
818 Egypt frgr
826 United Kingdom g
831 Guernsey eyuhy
832 Jersey greghr
833 Isle of Man a
834 Tanzania, United Republic of b
840 United States dee
850 Virgin Islands, U.S. rf
854 Burkina Faso fer
858 Uruguay frf
860 Uzbekistan erf
862 Venezuela, Bolivarian Republic of greghr
876 Wallis and Futuna gerg
882 Samoa yer
887 Yemen gtgtt
894 Zambia frgr
<!DOCTYPE html>
<meta charset="utf-8">
<style>
path {
stroke: white;
stroke-width: 0.25px;
}
#info {
position: absolute;
background: #fff;
background: -webkit-linear-gradient(top, #fff, #ccc, #fff);
font-family: Verdana, sans-serif;
font-size: 10pt;
padding: 3pt;
-webkit-border-radius: 6px;
-moz-border-radius: 6px;
border: thin solid #aaa;
border-radius: 6px;
-webkit-box-shadow: 4px 4px 4px rgba(0, 0, 0, 0.4);
-moz-box-shadow: 4px 4px 4px rgba(0, 0, 0, 0.4);
box-shadow: 4px 4px 4px rgba(0, 0, 0, 0.4);
}
#info.hidden {
display: none;
}
</style>
<body>
<div id="map"></div>
<div id="info" class="hidden"></div>
<script src="//d3js.org/d3.v4.js"></script>
<script src="topojson.js"></script>
<script src="https://d3js.org/d3-array.v1.min.js"></script>
<script src="https://d3js.org/d3-geo.v1.min.js"></script>
<script src="https://d3js.org/d3-geo-projection.v2.min.js"></script>
<script>
var width = 960,
height = 450;
var projection = d3.geoNaturalEarth2()
.center([30, 1 ])
.scale(194)
.rotate([0,0]);
var svg = d3.select("#map").append("svg")
.attr("width", width)
.attr("height", height);
var filter = svg.append("defs")
.append("filter")
.attr("id", "drop-shadow")
.attr("height", "110%");
filter.append("feGaussianBlur")
.attr("in", "SourceAlpha")
.attr("stdDeviation", 1)
.attr("result", "blur");
filter.append("feOffset")
.attr("in", "blur")
.attr("dx", 1)
.attr("dy", 1)
.attr("result", "offsetBlur");
var feMerge = filter.append("feMerge");
feMerge.append("feMergeNode")
.attr("in", "offsetBlur")
feMerge.append("feMergeNode")
.attr("in", "SourceGraphic");
var gradient = svg.append("svg:defs")
.append("svg:linearGradient")
.attr("id", "gradient")
.attr("x1", "0%")
.attr("y1", "0%")
.attr("x2", "0%")
.attr("y2", "100%")
.attr("spreadMethod", "pad");
gradient.append("svg:stop")
.attr("offset", "0%")
.attr("stop-color", "#0F3871")
.attr("stop-opacity", 1);
gradient.append("svg:stop")
.attr("offset", "100%")
.attr("stop-color", "#175BA8")
.attr("stop-opacity", 1);
var path = d3.geoPath()
.projection(projection);
var g = svg.append("g").attr("pointer-event","none");
var h = svg.append("g");
var idbyname = {};
d3.tsv("countrynames.tsv",function(names){
console.log(names);
names.forEach(function(d){
idbyname[d.id] = d.name;
});
});
var idbynameTexto = {};
d3.tsv("countrynames.tsv",function(texto){
console.log(texto);
texto.forEach(function(d){
idbynameTexto[d.id] = d.texto;
});
});
// load and display the World
d3.json("world-110m.json", function(error, topology) {
h.selectAll("path2")
.data(topojson.object(topology, topology.objects.countries)
.geometries)
.enter()
.append("path")
.attr("d", path)
.on("mouseover",function(d,i){
console.log(d.id);
d3.select(this).style('fill','#EB9A28');
document.getElementById("info").innerHTML = idbyname[d.id];
var xPosition = parseFloat(d3.event.pageX) + 15 ;
var yPosition = parseFloat(d3.event.pageY) - 15 ;
d3.select("#info")
.style("left", xPosition + "px")
.style("top", yPosition + "px")
;
d3.select("#info").classed("hidden",false);
//showText(text)
})
.on("mouseout",function(d,i){
d3.select(this).style('fill','none');
d3.select("#info").classed("hidden",true);
})
.on("mousemove",function(d,i){
var xPosition = parseFloat(d3.event.pageX) + 15 ;
var yPosition = parseFloat(d3.event.pageY) - 15 ;
d3.select("#info")
.style("left", xPosition + "px")
.style("top", yPosition + "px")
;
d3.select("#info").classed("hidden",false);
})
.on("click",function(d,i){
document.getElementById("text").innerHTML = idbynameTexto[d.id];
})
.attr("class",function(d,i){
return "country_" + d.id;
})
.style("fill","none")
.style("pointer-events","all")
.attr('cursor','pointer')
;
g.insert("path")
.datum(topojson.object(topology, topology.objects.land))
.attr("class", "land")
.attr("d", path)
.attr("pointer-events","none")
.style("filter", "url(#drop-shadow)")
.style("fill", "url(#gradient)")
;
g.insert("path")
.datum(topojson.mesh(topology, topology.objects.countries, function(a, b) { return a !== b; }))
.attr("class", "boundary")
.attr("d", path)
.style("fill","none")
.attr("pointer-events","none")
;
});
function showText(text){
document.getElementById("text").innerHTML=text;
};
function hide(){
document.getElementById("text").innerHTML="";
};
</script>
<div id="text"></div>
</body>
</html>
topojson = (function() {
function merge(topology, arcs) {
var arcsByEnd = {},
fragmentByStart = {},
fragmentByEnd = {};
arcs.forEach(function(i) {
var e = ends(i);
(arcsByEnd[e[0]] || (arcsByEnd[e[0]] = [])).push(i);
(arcsByEnd[e[1]] || (arcsByEnd[e[1]] = [])).push(~i);
});
arcs.forEach(function(i) {
var e = ends(i),
start = e[0],
end = e[1],
f, g;
if (f = fragmentByEnd[start]) {
delete fragmentByEnd[f.end];
f.push(i);
f.end = end;
if (g = fragmentByStart[end]) {
delete fragmentByStart[g.start];
var fg = g === f ? f : f.concat(g);
fragmentByStart[fg.start = f.start] = fragmentByEnd[fg.end = g.end] = fg;
} else if (g = fragmentByEnd[end]) {
delete fragmentByStart[g.start];
delete fragmentByEnd[g.end];
var fg = f.concat(g.map(function(i) { return ~i; }).reverse());
fragmentByStart[fg.start = f.start] = fragmentByEnd[fg.end = g.start] = fg;
} else {
fragmentByStart[f.start] = fragmentByEnd[f.end] = f;
}
} else if (f = fragmentByStart[end]) {
delete fragmentByStart[f.start];
f.unshift(i);
f.start = start;
if (g = fragmentByEnd[start]) {
delete fragmentByEnd[g.end];
var gf = g === f ? f : g.concat(f);
fragmentByStart[gf.start = g.start] = fragmentByEnd[gf.end = f.end] = gf;
} else if (g = fragmentByStart[start]) {
delete fragmentByStart[g.start];
delete fragmentByEnd[g.end];
var gf = g.map(function(i) { return ~i; }).reverse().concat(f);
fragmentByStart[gf.start = g.end] = fragmentByEnd[gf.end = f.end] = gf;
} else {
fragmentByStart[f.start] = fragmentByEnd[f.end] = f;
}
} else if (f = fragmentByStart[start]) {
delete fragmentByStart[f.start];
f.unshift(~i);
f.start = end;
if (g = fragmentByEnd[end]) {
delete fragmentByEnd[g.end];
var gf = g === f ? f : g.concat(f);
fragmentByStart[gf.start = g.start] = fragmentByEnd[gf.end = f.end] = gf;
} else if (g = fragmentByStart[end]) {
delete fragmentByStart[g.start];
delete fragmentByEnd[g.end];
var gf = g.map(function(i) { return ~i; }).reverse().concat(f);
fragmentByStart[gf.start = g.end] = fragmentByEnd[gf.end = f.end] = gf;
} else {
fragmentByStart[f.start] = fragmentByEnd[f.end] = f;
}
} else if (f = fragmentByEnd[end]) {
delete fragmentByEnd[f.end];
f.push(~i);
f.end = start;
if (g = fragmentByEnd[start]) {
delete fragmentByStart[g.start];
var fg = g === f ? f : f.concat(g);
fragmentByStart[fg.start = f.start] = fragmentByEnd[fg.end = g.end] = fg;
} else if (g = fragmentByStart[start]) {
delete fragmentByStart[g.start];
delete fragmentByEnd[g.end];
var fg = f.concat(g.map(function(i) { return ~i; }).reverse());
fragmentByStart[fg.start = f.start] = fragmentByEnd[fg.end = g.start] = fg;
} else {
fragmentByStart[f.start] = fragmentByEnd[f.end] = f;
}
} else {
f = [i];
fragmentByStart[f.start = start] = fragmentByEnd[f.end = end] = f;
}
});
function ends(i) {
var arc = topology.arcs[i], p0 = arc[0], p1 = [0, 0];
arc.forEach(function(dp) { p1[0] += dp[0], p1[1] += dp[1]; });
return [p0, p1];
}
var fragments = [];
for (var k in fragmentByEnd) fragments.push(fragmentByEnd[k]);
return fragments;
}
function mesh(topology, o, filter) {
var arcs = [];
if (arguments.length > 1) {
var geomsByArc = [],
geom;
function arc(i) {
if (i < 0) i = ~i;
(geomsByArc[i] || (geomsByArc[i] = [])).push(geom);
}
function line(arcs) {
arcs.forEach(arc);
}
function polygon(arcs) {
arcs.forEach(line);
}
function geometry(o) {
geom = o;
geometryType[o.type](o.arcs);
}
var geometryType = {
LineString: line,
MultiLineString: polygon,
Polygon: polygon,
MultiPolygon: function(arcs) { arcs.forEach(polygon); }
};
o.type === "GeometryCollection"
? o.geometries.forEach(geometry)
: geometry(o);
if (arguments.length < 3) for (var i in geomsByArc) arcs.push([i]);
else for (var i in geomsByArc) if (filter((geom = geomsByArc[i])[0], geom[geom.length - 1])) arcs.push([i]);
} else {
for (var i = 0, n = topology.arcs.length; i < n; ++i) arcs.push([i]);
}
return object(topology, {type: "MultiLineString", arcs: merge(topology, arcs)});
}
function object(topology, o) {
var tf = topology.transform,
kx = tf.scale[0],
ky = tf.scale[1],
dx = tf.translate[0],
dy = tf.translate[1],
arcs = topology.arcs;
function arc(i, points) {
if (points.length) points.pop();
for (var a = arcs[i < 0 ? ~i : i], k = 0, n = a.length, x = 0, y = 0, p; k < n; ++k) points.push([
(x += (p = a[k])[0]) * kx + dx,
(y += p[1]) * ky + dy
]);
if (i < 0) reverse(points, n);
}
function line(arcs) {
var points = [];
for (var i = 0, n = arcs.length; i < n; ++i) arc(arcs[i], points);
return points;
}
function polygon(arcs) {
return arcs.map(line);
}
function geometry(o) {
o = Object.create(o);
o.coordinates = geometryType[o.type](o.arcs);
return o;
}
var geometryType = {
LineString: line,
MultiLineString: polygon,
Polygon: polygon,
MultiPolygon: function(arcs) { return arcs.map(polygon); }
};
return o.type === "GeometryCollection"
? (o = Object.create(o), o.geometries = o.geometries.map(geometry), o)
: geometry(o);
}
function reverse(array, n) {
var t, j = array.length, i = j - n; while (i < --j) t = array[i], array[i++] = array[j], array[j] = t;
}
return {
version: "0.0.3",
mesh: mesh,
object: object
};
})();
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment