【问题标题】:Mapbox GL latest 0.26.0 Cannot read property 'id' of undefinedMapbox GL 最新 0.26.0 无法读取未定义的属性“id”
【发布时间】:2016-11-04 20:30:24
【问题描述】:

有没有人在最新的 mapbox gl 中遇到以下错误?这发生在地图的 setFilter 时。

VM5448:227 Uncaught TypeError: Cannot read property 'id' of undefined(…)
t.setFilter @ mapbox-gl.js?6b34:formatted:6061
e.setFilter @ mapbox-gl.js?6b34:formatted:10080
(anonymous function) @ map.service.ts?33cd:135SafeSubscriber.__tryOrUnsub @ VM5448:223
SafeSubscriber.next @ VM5448:172
Subscriber._next @ VM5448:125
Subscriber.next @ VM5448:89
handler @ VM5521:126
Evented.fire @ mapbox-gl.js?6b34:formatted:11031
h @ mapbox-gl.js?6b34:formatted:8249
u @ mapbox-gl.js?6b34:formatted:8213
ZoneDelegate.invokeTask @ zone.js?fad3:265
onInvokeTask @ core.umd.js?e2a5:6197ZoneDelegate.invokeTask @ zone.js?fad3:264
Zone.runTask @ zone.js?fad3:154ZoneTask.invoke @ zone.js?fad3:335

t.setFilter@mapbox-gl.js?6b34:formatted:6061

            t.prototype.setFilter = function(e, t) {
                this._checkLoaded();
                var r = this.getLayer(e);
                return null !== t && this._validate(validateStyle.filter, "layers." + r.id + ".filter", t) ? this : util.deepEqual(r.filter, t) ? this : (r.filter = util.clone(t),
                this._updateLayer(r))
            }

【问题讨论】:

  • 你能发布引发错误的代码吗?即你用什么称呼map.setFilter()。
  • 我的代码类似于:mapbox.com/mapbox-gl-js/example/hover-styles代码sn-p:Observable.fromEvent(this._map, "mousemove").subscribe( function(x: MapMouseEvent) { let features = this._map.queryRenderedFeatures(x.point, { layers: [this._layerId] }); if (features.length) { this._map.setFilter(this._layerId, ["all", ["==", "aaa", features[0].properties.aaa], ["==", "bbb", "B"]]); } else { this._map.setFilter(this._layerId, ["all", ["==", "aaa", ""], ["==", "bbb", "B"]]); } }.bind(this));

标签: mapbox-gl mapbox-gl-js


【解决方案1】:

这里已关闭。升级到 0.28.0

【讨论】:

    猜你喜欢
    • 2020-06-10
    • 2020-01-14
    • 1970-01-01
    • 1970-01-01
    • 2019-11-18
    • 2021-10-08
    • 2018-10-01
    • 2021-06-27
    • 2021-05-20
    相关资源
    最近更新 更多