var geojson; var geojsonUrl = document.getElementById('map').getAttribute('data-geojson'); $.getJSON(geojsonUrl, function (data) { geojson = L.geoJSON(data, { style: style, filter: picnicFilter, onEachFeature: onEachFeature }).addTo(map); if (geojson.getLayers().length) { map.fitBounds(geojson.getBounds(), { padding: [12, 12], animate: false }); } }); 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 je v getJSON výše // geolokace: var options = { flyTo: true, strings: { title: "Moje poloha", metersUnit: "metrů", feetUnit: "feet", popup: "Nacházíš se v okolí {distance} {unit} od tohoto bodu.", outsideMapBoundsMsg: "Zdá se, že jsi mimo oblast mapy." } } L.control.locate(options).addTo(map); // 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);