Skip to content

Commit f419fab

Browse files
author
hisham waleed karam
committed
raster support
1 parent a7b700c commit f419fab

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

Diff for: src/plots/mapbox/layers.js

+20-7
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ function isVisible(opts) {
131131

132132
return opts.visible && (
133133
Lib.isPlainObject(source) ||
134-
(typeof source === 'string' && source.length > 0)
134+
((typeof source === 'string' || Array.isArray(source)) && source.length > 0)
135135
);
136136
}
137137

@@ -193,29 +193,42 @@ function convertOpts(opts) {
193193
break;
194194
}
195195

196-
return { layout: layout, paint: paint };
196+
return {
197+
layout: layout,
198+
paint: paint
199+
};
197200
}
198201

199202
function convertSourceOpts(opts) {
200203
var sourceType = opts.sourcetype;
201204
var source = opts.source;
202-
var sourceOpts = {type: sourceType};
205+
var sourceOpts = {
206+
type: sourceType
207+
};
203208
var field;
204-
205-
if(sourceType === 'geojson') {
209+
if (sourceType === 'geojson') {
206210
field = 'data';
207-
} else if(sourceType === 'vector') {
211+
} else if (sourceType === 'vector') {
208212
field = typeof source === 'string' ? 'url' : 'tiles';
213+
} else if (sourceType === 'raster') {
214+
field = 'tiles';
215+
sourceOpts['tileSize'] = 256;
216+
for (let index = 0; index < source.length; index++) {
217+
const url = source[index];
218+
source[index] = decodeURIComponent(url);
219+
220+
}
209221
}
210222

211223
sourceOpts[field] = source;
224+
212225
return sourceOpts;
213226
}
214227

215228
module.exports = function createMapboxLayer(mapbox, index, opts) {
216229
var mapboxLayer = new MapboxLayer(mapbox, index);
217230

218231
mapboxLayer.update(opts);
219-
232+
220233
return mapboxLayer;
221234
};

Diff for: src/plots/mapbox/layout_attributes.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ var attrs = module.exports = overrideAll({
100100
},
101101
sourcetype: {
102102
valType: 'enumerated',
103-
values: ['geojson', 'vector'],
103+
values: ['geojson', 'vector', 'raster'],
104104
dflt: 'geojson',
105105
role: 'info',
106106
description: [
@@ -132,7 +132,7 @@ var attrs = module.exports = overrideAll({
132132

133133
type: {
134134
valType: 'enumerated',
135-
values: ['circle', 'line', 'fill', 'symbol'],
135+
values: ['circle', 'line', 'fill', 'symbol', 'raster'],
136136
dflt: 'circle',
137137
role: 'info',
138138
description: [

0 commit comments

Comments
 (0)