47 lines
1.3 KiB
JavaScript
47 lines
1.3 KiB
JavaScript
// Náhled obvodu v detailu — stejný podklad a rámeček jako na celé mapě.
|
|
(function () {
|
|
var el = document.getElementById('obvod-nahled');
|
|
if (!el || typeof L === 'undefined') {
|
|
return;
|
|
}
|
|
|
|
var obvodId = el.getAttribute('data-obvod');
|
|
var geojsonUrl = el.getAttribute('data-geojson');
|
|
if (!obvodId || !geojsonUrl) {
|
|
return;
|
|
}
|
|
|
|
var podklady = MapovePodklady.vytvor();
|
|
var map = L.map(el, {
|
|
center: [50.853501146, 14.8425],
|
|
zoom: 14,
|
|
layers: [MapovePodklady.vychozi(podklady)],
|
|
scrollWheelZoom: false,
|
|
});
|
|
MapovePodklady.logo(map, podklady);
|
|
|
|
function style() {
|
|
return {
|
|
fillColor: '#c5ddf6',
|
|
color: '#1d4f91',
|
|
weight: 2,
|
|
opacity: 1,
|
|
fillOpacity: 0.28,
|
|
};
|
|
}
|
|
|
|
$.getJSON(geojsonUrl, function (data) {
|
|
var layer = L.geoJSON(data, {
|
|
style: style,
|
|
filter: function (feature) {
|
|
return feature.properties && String(feature.properties.number) === String(obvodId);
|
|
},
|
|
}).addTo(map);
|
|
|
|
if (layer.getLayers().length) {
|
|
map.fitBounds(layer.getBounds(), { padding: [16, 16] });
|
|
}
|
|
map.invalidateSize();
|
|
});
|
|
})();
|