0

I'm getting the following error in Internet Explorer: " Object doesn't support property or method 'includes' "

The method 'includes' works fine in Chrome and Firefox but throws an error for each instance in IE.

This is an example of the code that is creating the error:

            var carmen56= new L.GeoJSON(null, {
            style: function (feature) {


                if (feature.properties.description.includes("Exclude")) {
                    return {
                        clickable: true,
                        weight: 1,
                        opacity: .80,
                        fillOpacity:  .55,
                        fillColor: '#55ff00',
                        color: '#000000'
                    };
                }; 
                if (feature.properties.description.includes("Include")) {
                    return {
                        clickable: true,
                        weight: 1,
                        opacity: .80,
                        fillOpacity:  .55,
                        fillColor: '#ffaa00', <!--Orange-->
                        color: '#000000'
                    };
                }; 

                if (feature.properties.description.includes("Tier 3")) {
                    return {
                        clickable: true,
                        weight: 1,
                        opacity: .80,
                        fillOpacity:  .55,
                        fillColor: '#ff0000',
                        color: '#ff0000'
                    };
                }; 
1

1 Answer 1

1

If includes doesn't work try something like this:

    // Set function for color ramp
    function getColor(league){
    return league == 'NL' ? 'blue' :
           league == 'AL' ? 'red' :
           'white';
           }

///////////////////////////////////

return L.circleMarker(latlng, {
    radius:6,
    opacity: .5,
    color:getColor(feature.properties.League),
    fillColor:  getColor(feature.properties.League),
    fillOpacity: 0.8

My example uses a getColor function that reads values from the League field in my GeoJSON file, and if the value is 'NL' returns 'blue', 'AL' returns 'red' and 'white' if it's something else. It avoids the includes function that IE is having a problem with.

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.