0

i am using openlayers3,

Fixing problem

Its working now geo.getFeatures();

$.getJSON('url', function(data) {
    geo = new ol.source.Vector({
        features: (new ol.format.GeoJSON()).readFeatures(data),
        projection: pixelProjection
    });
});

Problem

i am created source vector as

        geo = new ol.source.Vector({
            url: '/map/jsonmaps/systems/' + system + '/parts/' + chapter + '/' + selectElement.value + '.geojson',
            format: new ol.format.GeoJSON(),
            projection: pixelProjection,
            style: style
        })

after, i want getting this features for this used getFeatures(); function. But this function is returned empty array. After this method, i am try object parse,

console.log(geo);

Output Console

enter image description here

I am looking for geo.o and i writing console.log(geo.o); and this new output as:

enter image description here

Yes its here, but i could not getting data :D

console.log(geo['o'].length); //output is undefinded

for(item in geo.o){ // is not working
    console.log(item);
}

enter image description here

  • Possible duplicate of [Why is my variable unaltered after I modify it inside of a function? - Asynchronous code reference](http://stackoverflow.com/questions/23667086/why-is-my-variable-unaltered-after-i-modify-it-inside-of-a-function-asynchron) – JJJ Mar 26 '17 at 13:19
  • ...and the console behavior is explained by http://stackoverflow.com/questions/4057440/is-chromes-javascript-console-lazy-about-evaluating-arrays – JJJ Mar 26 '17 at 13:21

0 Answers0