0

So, my problem resides when creating a layer. then adding data to it later. but the style feature not taking control. and it adding default style.

Here is some code that I have. That creates a layer. Then adds data to that layer. But my problem is once the layer has been created and added. The layer won't render any new points with the style.

Is there a style option for the add data function?

let tlll = []; let map = this.map; let lc = this.lcontrol; let tll = null;
let ml = mapdata.layers; let a = null; let b = null; let c = null;
let smf = this.styleFeature;
   Object.keys(ml).forEach(function(k){
        tll =  L.geoJson().addTo(map, {pointToLayer:smf});
        a = k;
        Object.keys(ml[k]).forEach(function(v){
             console.log(v);
             b = v;
             Object.keys(ml[k][v]).forEach(function(vv){
                  tll.addData({
                       type: 'Point',
                       coordinates: [ml[k][v][vv].lng,ml[k][v][vv].lat],
                       properties: ml[k][v][vv]
                  });
        });
   });
   c = lc.addOverlay(tll,b,a);
   tlll.push(c);
});
this.testloclayer = tlll;
this.map.setView(tll.getBounds().getCenter());

1 Answer 1

1

the problem was in this part of the code.

tll =  L.geoJson().addTo(map, {pointToLayer:smf});

should be

tll =  L.geoJson(null, {pointToLayer:smf}).addTo(map);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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