Obvody/www/js/obvody.js

36 lines
743 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,
onEachFeature: onEachFeature
}).addTo(map);
// geolokace:
map.locate({ setView: true, 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);