47 lines
1002 B
JavaScript
47 lines
1002 B
JavaScript
// import souboru s obvody:
|
|
$.ajax({
|
|
'async': false,
|
|
'global': false,
|
|
'url': "../../data/geo-obvody.geojson",
|
|
'dataType': "json",
|
|
'success': function (data) {
|
|
geojsonFeature = data;
|
|
}
|
|
});
|
|
|
|
var geojson;
|
|
geojson = L.geoJSON(geojsonFeature, {
|
|
style: style,
|
|
filter: picnicFilter,
|
|
onEachFeature: onEachFeature
|
|
}).addTo(map);
|
|
|
|
function picnicFilter(feature) {
|
|
// obvod ID je z latte obvod_id
|
|
if (obvod_id == null) return true;
|
|
if (feature.properties.number == obvod_id) return true
|
|
}
|
|
|
|
// center na vybraný obvod:
|
|
map.flyToBounds(geojson.getBounds());
|
|
|
|
|
|
// geolokace:
|
|
map.locate({ setView: false, maxZoom: 16 });
|
|
|
|
function onLocationFound(e) {
|
|
var radius = e.accuracy;
|
|
|
|
L.marker(e.latlng).addTo(map)
|
|
.bindPopup("Nacházíte se v okolí " + radius + " metrů od tohoto bodu.").openPopup();
|
|
|
|
L.circle(e.latlng, radius).addTo(map);
|
|
}
|
|
|
|
map.on('locationfound', onLocationFound);
|
|
|
|
function onLocationError(e) {
|
|
alert(e.message);
|
|
}
|
|
|
|
map.on('locationerror', onLocationError); |