Skip to content

Commit b4dfd57

Browse files
committed
Expose mapbox minzoom, maxzoom, and symbol-placement properties
1 parent b880717 commit b4dfd57

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-1
lines changed

src/plots/mapbox/layers.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ proto.updateLayer = function(opts) {
9797
source: this.idSource,
9898
'source-layer': opts.sourcelayer || '',
9999
type: opts.type,
100+
minzoom: opts.minzoom,
101+
maxzoom: opts.maxzoom,
100102
layout: convertedOpts.layout,
101103
paint: convertedOpts.paint
102104
}, opts.below);
@@ -176,7 +178,8 @@ function convertOpts(opts) {
176178
'text-field': symbol.text,
177179
'text-size': symbol.textfont.size,
178180
'text-anchor': textOpts.anchor,
179-
'text-offset': textOpts.offset
181+
'text-offset': textOpts.offset,
182+
'symbol-placement': symbol.placement,
180183

181184
// TODO font family
182185
// 'text-font': symbol.textfont.family.split(', '),

src/plots/mapbox/layout_attributes.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,28 @@ var attrs = module.exports = overrideAll({
175175
role: 'info',
176176
description: 'Sets the opacity of the layer.'
177177
},
178+
minzoom: {
179+
valType: 'number',
180+
min: 0,
181+
max: 24,
182+
dflt: 0,
183+
role: 'info',
184+
description: [
185+
'Sets the minimum zoom level.',
186+
'At zoom levels less than the minzoom, the layer will be hidden.'
187+
].join(' ')
188+
},
189+
maxzoom: {
190+
valType: 'number',
191+
min: 0,
192+
max: 24,
193+
dflt: 24,
194+
role: 'info',
195+
description: [
196+
'Sets the maximum zoom level.',
197+
'At zoom levels equal to or greater than the maxzoom, the layer will be hidden.'
198+
].join(' ')
199+
},
178200

179201
// type-specific style attributes
180202
circle: {
@@ -240,6 +262,18 @@ var attrs = module.exports = overrideAll({
240262
'Sets the symbol text.'
241263
].join(' ')
242264
},
265+
placement: {
266+
valType: 'enumerated',
267+
values: ['point', 'line', 'line-center'],
268+
dflt: 'point',
269+
role: 'info',
270+
description: [
271+
'Sets the symbol placement.',
272+
'If `placement` is *point*, the label is placed where the geometry is located',
273+
'If `placement` is *line*, the label is placed along the line of the geometry',
274+
'If `placement` is *line-center*, the label is placed on the center of the geometry',
275+
].join(' ')
276+
},
243277
textfont: fontAttr,
244278
textposition: Lib.extendFlat({}, textposition, { arrayOk: false })
245279
}

src/plots/mapbox/layout_defaults.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ function handleLayerDefaults(layerIn, layerOut) {
6262
coerce('below');
6363
coerce('color');
6464
coerce('opacity');
65+
coerce('minzoom');
66+
coerce('maxzoom');
6567

6668
if(type === 'circle') {
6769
coerce('circle.radius');
@@ -82,6 +84,7 @@ function handleLayerDefaults(layerIn, layerOut) {
8284
coerce('symbol.text');
8385
Lib.coerceFont(coerce, 'symbol.textfont');
8486
coerce('symbol.textposition');
87+
coerce('symbol.placement');
8588
}
8689
}
8790
}

0 commit comments

Comments
 (0)