Skip to content

Commit 153c6b4

Browse files
committed
add support for sourcetype: 'image' layers
1 parent 0c99017 commit 153c6b4

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

src/plots/mapbox/layers.js

+3
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,9 @@ function convertSourceOpts(opts) {
212212
} else if(sourceType === 'raster') {
213213
field = 'tiles';
214214
sourceOpts.tileSize = 256;
215+
} else if(sourceType === 'image') {
216+
field = 'url';
217+
sourceOpts.coordinates = opts.coordinates;
215218
}
216219

217220
sourceOpts[field] = source;

src/plots/mapbox/layout_attributes.js

+13-3
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,11 @@ var attrs = module.exports = overrideAll({
102102
},
103103
sourcetype: {
104104
valType: 'enumerated',
105-
values: ['geojson', 'vector', 'raster'],
105+
values: ['geojson', 'vector', 'raster', 'image'],
106106
dflt: 'geojson',
107107
role: 'info',
108108
description: [
109-
'Sets the source type for this layer.',
110-
'Support for *raster*, *image* and *video* source types is coming soon.'
109+
'Sets the source type for this layer.'
111110
].join(' ')
112111
},
113112

@@ -145,6 +144,17 @@ var attrs = module.exports = overrideAll({
145144
].join(' ')
146145
},
147146

147+
coordinates: {
148+
valType: 'any',
149+
role: 'info',
150+
description: [
151+
'Sets the coordinates array contains [longitude, latitude] pairs',
152+
'for the image corners listed in clockwise order:',
153+
'top left, top right, bottom right, bottom left.',
154+
'Only has an effect for *image* `sourcetype`.'
155+
].join(' ')
156+
},
157+
148158
// attributes shared between all types
149159
below: {
150160
valType: 'string',

src/plots/mapbox/layout_defaults.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,13 @@ function handleLayerDefaults(layerIn, layerOut) {
5454
var sourceType = coerce('sourcetype');
5555
coerce('source');
5656

57-
if(sourceType === 'vector') coerce('sourcelayer');
57+
if(sourceType === 'vector') {
58+
coerce('sourcelayer');
59+
}
60+
61+
if(sourceType === 'image') {
62+
coerce('coordinates');
63+
}
5864

5965
// maybe add smart default based off GeoJSON geometry?
6066
var type = coerce('type');

0 commit comments

Comments
 (0)