Skip to content

Instantly share code, notes, and snippets.

@misaon
Created November 27, 2017 11:10
Show Gist options
  • Save misaon/12ae7a50371a236dcb9bcb27f1f7a8a4 to your computer and use it in GitHub Desktop.
Save misaon/12ae7a50371a236dcb9bcb27f1f7a8a4 to your computer and use it in GitHub Desktop.
Google mapka s hromadou bodů z webu aktalne
<script type="text/javascript">
// switch (LIB_GRAPHICS.device) {
// case "smart":
// jQuery('.grafika-obal').addClass('smart');
// break;
// default:
// jQuery('.grafika-obal').addClass('desktop');
// }
poleStran = [];
poleStran['ANO'] = ['ANO', '1If1debMrGzi23Sd6FLc5bFIqeuDp6jb4GYl0ajwG'];
poleStran['ČSSD'] = ['ČSSD', '119cd6R-9ffcZrWzgqCk7Mj7s6JcXDA0XqOru_iwQ'];
poleStran['KDU-ČSL'] = ['KDU-ČSL', '1PdCny11nfCyHlFxqKZxDqNk-7B_pPaIkAHwNer2i'];
poleStran['KSČM'] = ['KSČM', '1qYWNHMhdlW5V45hYjNfOtDhrBKSyrnwN1GTb5lGe'];
poleStran['ODS'] = ['ODS', '1V5GsxwerXq5onri1EnuNiNHACqpqPOZgmP-85WRb'];
poleStran['Piráti'] = ['Piráti', '1_ZxukbZ1frfFQzgiB7s959e342lq7kxIAqAUaumN'];
poleStran['SPD'] = ['SPD / Úsvit', '1aN6WmAi1YK0WKdYJZuihIIlTQ3IR9-FPBkxrwJGa'];
poleStran['TOP09'] = ['TOP 09', '1-yix1gqaIct8TIVs_ycSXmZfdjpk6Kwd3MVPQF1z'];
poleStran['Zelení'] = ['Zelení', '1aez2ys74yQfrn4AxyIbZf4sj1vexBv_cwF75b1Hh'];
// function sklonujHl(nStr) {
// var hlasy = Number(nStr);
// var dopln = ' hlasů';
// if (hlasy == 1) {
// dopln = ' hlas';
// } else if (hlasy == 2 || hlasy == 3 || hlasy == 4) {
// dopln = ' hlasy';
// }
// return (dopln);
// }
var infowindow = new google.maps.InfoWindow({
size: new google.maps.Size(150, 50)
});
var layer;
var map;
var vyber = '';
function pripojMapu(idDat) {
jQuery('.mapa-obal').html('<div id="map_canvas" style="width:100%; height:570px;"></div>');
var mapaVysledku = new google.maps.LatLng(49.7, 15.4);
map = new google.maps.Map(document.getElementById('map_canvas'), {
center: mapaVysledku,
zoom: 7,
minZoom: 7,
maxZoom: 12,
mapTypeControl: false,
streetViewControl: false,
fullscreenControl: false,
zoomControlOptions: {
position: google.maps.ControlPosition.RIGHT_TOP
},
mapTypeId: 'roadmap'
});
zmenVrstvu(idDat);
}
function zmenVrstvu(idDat){
layer = new google.maps.FusionTablesLayer({
query: {
select: 'lat',
from: idDat
},
styles: [{
where: "'porovnani' = -1",
markerOptions: {
iconName: 'small_red'
}
}, {
where: "'porovnani' = 1",
markerOptions: {
iconName: 'small_blue'
}
}, {
where: "'porovnani' = 0",
markerOptions: {
iconName: 'measle_grey'
}
}],
suppressInfoWindows: true
});
layer.setMap(map);
google.maps.event.addListener(layer, 'click', function (e) {
var idObce = e.row['id'].value;
var nazevObce = e.row['nazev'].value;
var hlasy13 = Number(e.row['hlasy-13'].value);
var procenta13 = e.row['proc-13'].value;
var hlasy17 = Number(e.row['hlasy-17'].value);
var procenta17 = e.row['proc-17'].value;
var htmlStr = '<div style="width:100%; padding-right:0%; position:relative;">';
htmlStr += '<h3><a href="https://zpravy.aktualne.cz/domaci/volby/volebni-infografika-ps-2017/r~191f2eecb57c11e7a9d00025900fea04/#' + idObce + '" target="_blank">' + nazevObce + '</a></h3>';
htmlStr += '<p class="clearfix hlavni-sdeleni">';
if (Number(procenta17) > Number(procenta13)) {
htmlStr += 'Strana získala <span style="color:#2785A5; font-weight: bold;">více % hlasů</span> než v minulých volbách.';
} else if (Number(procenta17) < Number(procenta13)) {
htmlStr += 'Strana získala <span style="color:#CA372C; font-weight: bold;">méně % hlasů</span> než v minulých volbách.';
} else {
htmlStr += 'Strana dosáhla stejného procentního zisku.';
}
htmlStr += '</p>';
htmlStr += '<p class="clearfix vysledky">';
htmlStr += '<span style="width:50%; float: left;"><span class="sp-rok">rok 2013</span>';
htmlStr += procenta13 + ' % ';
htmlStr += '<span class="sp-hlasy">' + hlasy13 + sklonujHl(hlasy13) + '</span>';
htmlStr += '</span>';
htmlStr += '<span style="width:50%; float: left;"><span class="sp-rok">rok 2017</span>';
htmlStr += procenta17 + ' % ';
htmlStr += '<span class="sp-hlasy">' + hlasy17 + sklonujHl(hlasy17) + '</span>';
htmlStr += '</span>';
htmlStr += '</p>';
htmlStr += '<p class="spodni-odkaz"><a href="https://zpravy.aktualne.cz/domaci/volby/volebni-infografika-ps-2017/r~191f2eecb57c11e7a9d00025900fea04/#' + idObce + '"" target="_blank">kompletní výsledky</a></p>';
htmlStr += '</div>';
var newContent = htmlStr;
infowindow.setOptions({
content: newContent,
pixelOffset: e.pixelOffset,
position: e.latLng
});
infowindow.open(map);
LIB_GRAPHICS.userClick();
})
}
pripojMapu(poleStran['ANO'][1]);
jQuery('.seznam-stran a').on('click', function (e) {
var id = jQuery(this).attr('rel');
if (id != vyber) {
layer.setMap(null);
infowindow.close();
if (poleStran[id][1].length > 1) {
zmenVrstvu(poleStran[id][1]);
}
jQuery('.legenda .nazev-strany').html(poleStran[id][0]);
jQuery('.seznam-stran a').removeClass('vybr');
jQuery(this).addClass('vybr');
vyber = id;
LIB_GRAPHICS.userClick();
}
e.preventDefault();
});
// var nactiTag1 = new NactiMRSSTagu('.souvisejici', 0);
// nactiTag1.currentDiv = jQuery('.current-graphic-6e1cee0964d0762ddaaf3a980fc3f2bc .souvisejici');
// nactiTag1.pocetSloupcu = 3;
// nactiTag1.pocetZobrazenychRadku = 2;
// nactiTag1.skrytaIdClanku = ['9349d324b37011e79142002590604f2e'];
// nactiTag1.nactiRss('i%3Akeyword%3A945');
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment