javascript - 我的带有 "all"运算符的 Mapbox 表达式有什么问题?

标签 javascript filter mapbox geojson

我有一个包含多个多边形的 geojson。每个多边形都有一个名称。我想显示除“boundingBox”之外的所有多边形。我在 addLayer() 中使用过滤器:

"filter": ["all",["==", "$type", "Polygon"],["!=",["string", ['get', 'name'],""], "boundingBox"]]

但没有出现多边形。

如果我这样做:

"filter": ["==", "$type", "Polygon"]

显示所有多边形。

这里出了什么问题?

最佳答案

看起来您混合使用了已弃用的过滤器语法 ($type) 和表达式语法,这是不允许的。

Expression syntax and the deprecated syntax below cannot be mixed in a single filter definition. https://docs.mapbox.com/mapbox-gl-js/style-spec/#other-filter

尝试

"filter": ["all",["==", ["geometry-type"], "Polygon"],["!=",["string", ['get', 'name'],""], "boundingBox"]]

关于javascript - 我的带有 "all"运算符的 Mapbox 表达式有什么问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56833912/

相关文章:

javascript - 如何从 iFrame 中重新加载主页

php - SQL 行回显到 Javascript 时出现问题,错误 SyntaxError : unterminated string literal

Mapbox GL JS : Trouble creating hover effects on mouseenter and mouseleave when layers are stacked (z-index)

javascript - 无法处理绑定(bind),国家/地区未定义

javascript - 单击 <li> 时,将 <li> 中的值拉入 &lt;textarea&gt;

引用 dplyr 中的一系列列

angularjs - 与父值匹配的 Angular 嵌套ng-repeat过滤器项

filter - DrRacket/Scheme 中的 map 、过滤器、文件夹

postgresql - 如何有效地将大型 PostGIS (PostgreSQL) 表导出到 GeoJSON 文件?

leaflet - 如何在弹出窗口中隐藏尾部三角形