Built with blockbuilder.org
Created
July 27, 2017 01:23
-
-
Save anonymous/12d8564cd486a458066a0e43b71c14ad to your computer and use it in GitHub Desktop.
mapa mundi
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
license: mit |
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
id | name | |
---|---|---|
-1 | Northern Cyprus | |
-2 | Kosovo | |
-3 | Somaliland | |
4 | Afghanistan | |
8 | Albania | |
10 | Antarctica | |
12 | Algeria | |
16 | American Samoa | |
20 | Andorra | |
24 | Angola | |
28 | Antigua and Barbuda | |
31 | Azerbaijan | |
32 | Argentina | |
36 | Australia | |
40 | Austria | |
44 | Bahamas | |
48 | Bahrain | |
50 | Bangladesh | |
51 | Armenia | |
52 | Barbados | |
56 | Belgium | |
60 | Bermuda | |
64 | Bhutan | |
68 | Bolivia, Plurinational State of | |
70 | Bosnia and Herzegovina | |
72 | Botswana | |
74 | Bouvet Island | |
76 | Brazil | |
84 | Belize | |
86 | British Indian Ocean Territory | |
90 | Solomon Islands | |
92 | Virgin Islands, British | |
96 | Brunei Darussalam | |
100 | Bulgaria | |
104 | Myanmar | |
108 | Burundi | |
112 | Belarus | |
116 | Cambodia | |
120 | Cameroon | |
124 | Canada | |
132 | Cape Verde | |
136 | Cayman Islands | |
140 | Central African Republic | |
144 | Sri Lanka | |
148 | Chad | |
152 | Chile | |
156 | China | |
158 | Taiwan, Province of China | |
162 | Christmas Island | |
166 | Cocos (Keeling) Islands | |
170 | Colombia | |
174 | Comoros | |
175 | Mayotte | |
178 | Congo | |
180 | Congo, the Democratic Republic of the | |
184 | Cook Islands | |
188 | Costa Rica | |
191 | Croatia | |
192 | Cuba | |
196 | Cyprus | |
203 | Czech Republic | |
204 | Benin | |
208 | Denmark | |
212 | Dominica | |
214 | Dominican Republic | |
218 | Ecuador | |
222 | El Salvador | |
226 | Equatorial Guinea | |
231 | Ethiopia | |
232 | Eritrea | |
233 | Estonia | |
234 | Faroe Islands | |
238 | Falkland Islands (Malvinas) | |
239 | South Georgia and the South Sandwich Islands | |
242 | Fiji | |
246 | Finland | |
248 | Aland Islands | |
250 | France | |
254 | French Guiana | |
258 | French Polynesia | |
260 | French Southern Territories | |
262 | Djibouti | |
266 | Gabon | |
268 | Georgia | |
270 | Gambia | |
275 | Palestinian Territory, Occupied | |
276 | Germany | |
288 | Ghana | |
292 | Gibraltar | |
296 | Kiribati | |
300 | Greece | |
304 | Greenland | |
308 | Grenada | |
312 | Guadeloupe | |
316 | Guam | |
320 | Guatemala | |
324 | Guinea | |
328 | Guyana | |
332 | Haiti | |
334 | Heard Island and McDonald Islands | |
336 | Holy See (Vatican City State) | |
340 | Honduras | |
344 | Hong Kong | |
348 | Hungary | |
352 | Iceland | |
356 | India | |
360 | Indonesia | |
364 | Iran, Islamic Republic of | |
368 | Iraq | |
372 | Ireland | |
376 | Israel | |
380 | Italy | |
384 | Cote d'Ivoire | |
388 | Jamaica | |
392 | Japan | |
398 | Kazakhstan | |
400 | Jordan | |
404 | Kenya | |
408 | Korea, Democratic People's Republic of | |
410 | Korea, Republic of | |
414 | Kuwait | |
417 | Kyrgyzstan | |
418 | Lao People's Democratic Republic | |
422 | Lebanon | |
426 | Lesotho | |
428 | Latvia | |
430 | Liberia | |
434 | Libya | |
438 | Liechtenstein | |
440 | Lithuania | |
442 | Luxembourg | |
446 | Macao | |
450 | Madagascar | |
454 | Malawi | |
458 | Malaysia | |
462 | Maldives | |
466 | Mali | |
470 | Malta | |
474 | Martinique | |
478 | Mauritania | |
480 | Mauritius | |
484 | Mexico | |
492 | Monaco | |
496 | Mongolia | |
498 | Moldova, Republic of | |
499 | Montenegro | |
500 | Montserrat | |
504 | Morocco | |
508 | Mozambique | |
512 | Oman | |
516 | Namibia | |
520 | Nauru | |
524 | Nepal | |
528 | Netherlands | |
531 | Curacao | |
533 | Aruba | |
534 | Sint Maarten (Dutch part) | |
535 | Bonaire, Sint Eustatius and Saba | |
540 | New Caledonia | |
548 | Vanuatu | |
554 | New Zealand | |
558 | Nicaragua | |
562 | Niger | |
566 | Nigeria | |
570 | Niue | |
574 | Norfolk Island | |
578 | Norway | |
580 | Northern Mariana Islands | |
581 | United States Minor Outlying Islands | |
583 | Micronesia, Federated States of | |
584 | Marshall Islands | |
585 | Palau | |
586 | Pakistan | |
591 | Panama | |
598 | Papua New Guinea | |
600 | Paraguay | |
604 | Peru | |
608 | Philippines | |
612 | Pitcairn | |
616 | Poland | |
620 | Portugal | |
624 | Guinea-Bissau | |
626 | Timor-Leste | |
630 | Puerto Rico | |
634 | Qatar | |
638 | Reunion | |
642 | Romania | |
643 | Russian Federation | |
646 | Rwanda | |
652 | Saint Barthelemy | |
654 | Saint Helena, Ascension and Tristan da Cunha | |
659 | Saint Kitts and Nevis | |
660 | Anguilla | |
662 | Saint Lucia | |
663 | Saint Martin (French part) | |
666 | Saint Pierre and Miquelon | |
670 | Saint Vincent and the Grenadines | |
674 | San Marino | |
678 | Sao Tome and Principe | |
682 | Saudi Arabia | |
686 | Senegal | |
688 | Serbia | |
690 | Seychelles | |
694 | Sierra Leone | |
702 | Singapore | |
703 | Slovakia | |
704 | Viet Nam | |
705 | Slovenia | |
706 | Somalia | |
710 | South Africa | |
716 | Zimbabwe | |
724 | Spain | |
728 | South Sudan | |
729 | Sudan | |
732 | Western Sahara | |
740 | Suriname | |
744 | Svalbard and Jan Mayen | |
748 | Swaziland | |
752 | Sweden | |
756 | Switzerland | |
760 | Syrian Arab Republic | |
762 | Tajikistan | |
764 | Thailand | |
768 | Togo | |
772 | Tokelau | |
776 | Tonga | |
780 | Trinidad and Tobago | |
784 | United Arab Emirates | |
788 | Tunisia | |
792 | Turkey | |
795 | Turkmenistan | |
796 | Turks and Caicos Islands | |
798 | Tuvalu | |
800 | Uganda | |
804 | Ukraine | |
807 | Macedonia, the former Yugoslav Republic of | |
818 | Egypt | |
826 | United Kingdom | |
831 | Guernsey | |
832 | Jersey | |
833 | Isle of Man | |
834 | Tanzania, United Republic of | |
840 | United States | |
850 | Virgin Islands, U.S. | |
854 | Burkina Faso | |
858 | Uruguay | |
860 | Uzbekistan | |
862 | Venezuela, Bolivarian Republic of | |
876 | Wallis and Futuna | |
882 | Samoa | |
887 | Yemen | |
894 | Zambia |
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> | |
<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> | |
var width = 960, | |
height = 450; | |
var projection = d3.geoMercator() | |
.center([2, 5 ]) | |
.scale(150) | |
.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; | |
}); | |
}); | |
// 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); | |
}) | |
.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); | |
}) | |
.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") | |
; | |
}); | |
</script> | |
</body> | |
</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
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 | |
}; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment