0

I am trying to populate popups on each polygon and style the layer according to type of commodity. Popups are empty and style doesn't work.

Code shown below:

lyrlicences = new L.GeoJSON.AJAX('data/Tzlicences.geojson',{style:stylePolygons, onEachFeature:returnPolygons}).addTo(tzmap);
        
function stylePolygons(json){
    var att = json.properties;
       if(att.commoditie =='Gold'){
        return {color: 'yellow', weight:3}
       }
       
       if(att.commoditie =='Copper'){
        return {color: 'brown', weight:3}
       }
      else {
        return {color: 'red', weight:5}
       }  
}

function returnPolygons(json, layer){
  layer.bindPopup(json.properties.commoditie);
}  
4
  • Trying to populate popups on each polygon and style the layer according to type of commodity
    – Lawi
    Commented Aug 13, 2021 at 11:57
  • Any errors in the browser debugger console or debugger network section?
    – TomazicM
    Commented Aug 13, 2021 at 12:16
  • No any error message from the Console
    – Lawi
    Commented Aug 13, 2021 at 12:38
  • Have a look at my answer to the question gis.stackexchange.com/questions/345177/….
    – TomazicM
    Commented Aug 13, 2021 at 12:58

0

Your Answer

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

Browse other questions tagged or ask your own question.