mapbox/mapbox-gl-js

Allow image source without image/coordinates

开放

#10,802 创建于 2021年6月24日

 (2 条评论) (0 个反应) (1 位负责人)JavaScript (2,203 个派生)batch import
good first issue

仓库指标

星标
 (10,532 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

Motivation

I often use this pattern for GeoJSON sources:

  1. addSource('mysource', { type: 'geojson', data: { type:'FeatureCollection', features: [] }});
  2. addLayer({ id: 'mylayer', source: 'mysource' })
  3. Now fetch the actual data, manipulate it, and call setData() to set it.

I do this because:

  • I need to fetch the data asynchronously (but I don't want to hold up all my other init)
  • I want the layer to be in a predictable place in the style (which I wouldn't get if I waited for the data to load before creating the source and the layer).

This doesn't work with the Image type because you have to provide some kind of actual data.

It would be more flexible thus if the image type didn't require data, like the geojson type.

贡献者指南