1

I generated this geojson data in my server:

{"type":"MultiLineString","coordinates":[[30.0212,40.123],[30.0229,40.1235],[30.0246,40.1239],[30.0262,40.1241],[30.027,40.1241],[30.0283,40.1241]]}

in ol3 I did:

// data above the client via ajax
$.each(data , function (k,v) {
     console.log(k,v);

      var g1=JSON.parse(v);

      var vectorFeature = new ol.Feature({                    
                geometry: g1 ,                                       
      });

      featuresArr.push(vectorFeature); 

})

var vectorSource = new ol.source.Vector();

vectorSource.addFeatures(featuresArr);

var yol2=new ol.layer.Vector({               
            projection: 'EPSG:3857',
            source: [vectorSource]
        });

if( yol2 instanceof ol.layer.Vector) {
                  // alert("yol2");
                  olTrMap.addLayer( yol2);

               }

Then nothing is displayed.

Do you have any idea?

2

See this question Add feature manually to a vector layer.

coordinates should be transform. check your coordinate system.

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.