tombatossals / angular-leaflet-directive

AngularJS directive to embed an interact with maps managed by Leaflet library
http://tombatossals.github.io/angular-leaflet-directive
MIT License
1.5k stars 635 forks source link

Attach a style to each feature of geojson #1142

Open sayush opened 8 years ago

sayush commented 8 years ago

I've got a geojson file of US states. I want to generate a heatmap like visualization by painting each of these features differently. I've done it before (without angular) by implementing something like this: http://gis.stackexchange.com/questions/75590/setstyle-function-for-geojson-features-leaflet

However, when I try it with angular-leaflet like this,

geojson.style = {
    fillColor: getStyle, // getStyle does not get called. 
    weight: 2,
    opacity: 1,
    color: 'black',
 };

function getStyle(f){
    console.log(f); //f is undefined
}

I'm confused on how to pass the feature to the function. The geojson feature in my case has properties like count which i use to pick appropriate color. Thanks.

sudhirbitsgoa commented 8 years ago

+1

sayush commented 8 years ago

I ended up accessing the map object and changing it there. Let me know if y'all find a better alternative.

Simon-GHI commented 6 years ago

No solution ?