2

I am using the leaflet.pattern library at https://github.com/teastman/Leaflet.pattern

and I want to change the color of my stripes based on a value in the feature just like I do in the following using a getColor Function as part of the style.

function getColor2(d) {
    return d == 9 ? '#d73027':
           d == 8 ? '#f46d43':
           d == 7 ? '#fdae61':
           d == 6 ? '#fee08b':
           d == 5 ? '#ffffbf':
           d == 4 ? '#d9ef8b':
           d == 3 ? '#a6d96a':
           d == 2 ? '#66bd63':
           d == 1 ? '#1a9850':
                '#1a9850';
}

However since the pattern is already defined I am not able to change the color on the fly based on the feature value.

See example at http://jsbin.com/vepiru/1/edit?js,console,output

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.