简体   繁体   中英

Mapbox GL JS ignore property expression

I'm trying to make geojson layer of polygons with diffrent fills. Some of them need to use "fill-patern" so they have "fill-patern" property, but some of them don't. I'm getting both of the "fill-patern" and "fill-color" proreties by expressions:

   paint: {
            "fill-pattern": ["get", "fill-pattern"],
            "fill-color": ["get", "fill-color"],
          },

But "fill-patern" property with any value (even null, or undefined) makes layer ignore "fill-color" property of this feature. So is that possible to fully ignore property if feature doesn't have it?

You're correct that, as noted in the documentation for the fill-color property here , fill-color is disabled by fill-pattern . In this scenario, the best approach would be to make two separate layers, one for the polygons that need to use fill-pattern and one for the polygons that don't. You could either use the same source for each layer and apply a filter expression as needed, or break up your original source into two separate sources.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM