mapbox/mapbox-gl-js

getStyle then setStyle broken for raster-dem

Open

#8,506 创建于 2019年7月18日

在 GitHub 查看
 (1 评论) (0 反应) (0 负责人)JavaScript (10,532 star) (2,203 fork)batch import
bug :lady_beetle:good first issue

描述

mapbox-gl-js version: tested on 1.1.0, probably since forever

browser: Chrome 75.0.3770.100 (Official Build) (64-bit)

Steps to Trigger Behavior

  1. setStyle on a style with raster-dem source
  2. getStyle anytime
  3. setStyle with serialized style object from getStyle

Link to Demonstration

https://jsfiddle.net/srmanc/L20ha5um/1/

Expected Behavior

setStyle should work without error msgs

Actual Behavior

setStyle breaks because bounds and url are set on source but are undefined. Sometimes tiles is undefined on source as well. There are actually two issues:

  1. Why does setStyle break at all if some undefined properties are set on source (this only happens for raster-dem type).
  2. When is it acceptable to call getStyle() to get all the relevant properties on sources - they are set initially so there would be no point in not setting them right away - however, tiles property is missing at the first "styledata" event - please review the jsfiddle example with console.log msgs for more input. We can make this work using delete operator but this seems like a nasty bug.

贡献者指南