1

I need to load my Geojson file before start my script . I need to load file before start this script :

var geojsonPrecitany = false;
var geojson = $.getJSON("./tematicke_vrstvy/tematicka_vrstva.geojson", function() {
    geojsonPrecitany = true;
});

Which checked that geojson is loaded ( if loaded geojsonPrecitany = true ).

OR

I need the solution how to load geojson file before start script with map (in Openlayers v3)

Because the work with geojson in js is asynchronous so i need to have the file peloaded before i start work with them in map script.

1

Start the map from a function that is called as a callback of your getJSON call, i.e.:

function initMap(){
   var map = new ol.Map({...});
}

var geojsonPrecitany = false;
var geojson = $.getJSON("./tematicke_vrstvy/tematicka_vrstva.geojson", function() {
    geojsonPrecitany = true;
    initMap();
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.