xxxxxxxxxx
<html>
<head>
<title>Presidential Election, El Salvador 2014, 1st Round</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="initial-scale=1.0, user-scalable=no"/>
<script src="https://code.jquery.com/jquery-1.8.2.min.js"></script>
<script>
// see https://leafletjs.com/reference.html
L_PREFER_CANVAS = true;
</script>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.2/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdn.leafletjs.com/leaflet-0.6.4/leaflet.css" />
<!--[if lte IE 8]>
<link rel="stylesheet" href="https://cdn.leafletjs.com/leaflet-0.6.4/leaflet.ie.css" />
<![endif]-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.6.4/leaflet.min.js"></script>
<!--<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/d3@1.29.5/d3.js"></script>-->
<style type="text/css">
html, body, #map {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
.leaflet-tile-pane {
opacity: .3
}
</style>
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="#">Presidential Election, El Salvador 2014, 1st Round</a>
</div>
</div>
</div>
<div style="position:fixed;top:50px;z-index:1000;">
<div class="alert alert-info" >
The <strong>size</strong> of bubbles represents number of voters, the <strong>color</strong> represents the winner and the <strong>oppacity</strong> the margin of victory.
<span style="color:#800">Salvador Sánchez Cerén (FMLN)</span> vs. <span style="color:#008">Norman Noel Quijano González (ARENA)</span> (99 % of votes counted)
</div>
</div>
<div id="map" style="margin-top:40px;"></div>
<script type="text/javascript">
// Create the map
var map = L.map('map',{zoomControl: false}).setView([13.68,-88.78], 9);
map.addControl( L.control.zoom({position: 'topright'}) );
// add an OpenStreetMap tile layer
// also see https://wiki.openstreetmap.org/wiki/Tiles
//L.tileLayer('https://{s}.tile.osm.org/{z}/{x}/{y}.png', {
L.tileLayer('https://{s}.www.toolserver.org/tiles/bw-mapnik/{z}/{x}/{y}.png', {
attribution: '© <a href="https://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
//add circles
//$.getJSON( "cz_president_2013_both_2_ring.json", function (data) {
$.getJSON( "sv_2014_1_ring.json", function (data) {
$.each(data, function (index, value) {
sum = 0;
descr = '';
$.each(value['person'], function (i,d) {
sum = sum + parseInt(d['population']);
descr += d['name'] + " (" + d['population'] + ")<br>";
})
circle = L.circle(
[value.coordinates[0], value.coordinates[1]],
Math.sqrt(sum*600),
{
color: values2color(value['winner']),
fillColor: values2color(value['winner']),
fillOpacity: 2*(Math.max(parseInt(value.person.p6.population),parseInt(value.person.p9.population)) / (parseInt(value.person.p6.population)+parseInt(value.person.p9.population))-0.5),
//fillOpacity: .8,
weight: 0.1,
//className: value.classname, //this does not seem to work, so hacked by class2color
}).addTo(map);
circle.bindPopup("<strong>" + value.name + "</strong><br>" + "<strong>" + value.winner + '</strong><br>' + descr);
});
});
function values2color(w) {
if (w == 'Salvador Sánchez Cerén (FMLN)') return '#f00';
if (w == 'Norman Noel Quijano González (ARENA)') return '#00f';
}
</script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-8592359-13', 'ocks.org');
ga('send', 'pageview');
</script>
</body>
</html>
Modified http://code.jquery.com/jquery-1.8.2.min.js to a secure url
Modified http://cdn.leafletjs.com/leaflet-0.6.4/leaflet.js to a secure url
Modified http://mbostock.github.com/d3/d3.js?1.29.1 to a secure url
https://code.jquery.com/jquery-1.8.2.min.js
https://cdn.leafletjs.com/leaflet-0.6.4/leaflet.js
https://mbostock.github.com/d3/d3.js?1.29.1