🎨 adding ref(erence) support for layer styles

This commit is contained in:
Michael Straßburger 2016-11-10 02:20:44 +01:00
parent e3f42e46c9
commit caea4c6aec

View File

@ -22,13 +22,15 @@ module.exports = class Styler
@_replaceConstants json.constants, json.layers if json.constants @_replaceConstants json.constants, json.layers if json.constants
for style in json.layers for style in json.layers
continue if style.ref if style.ref and @styleById[style.ref]
for ref in ['type', 'source-layer', 'minzoom', 'maxzoom', 'filter']
if @styleById[style.ref][ref] and not style[ref]
style[ref] = @styleById[style.ref][ref]
style.appliesTo = @_compileFilter style.filter style.appliesTo = @_compileFilter style.filter
@styleByLayer[style['source-layer']] ?= [] @styleByLayer[style['source-layer']] ?= []
@styleByLayer[style['source-layer']].push style @styleByLayer[style['source-layer']].push style
@styleById[style.id] = style @styleById[style.id] = style
getStyleFor: (layer, feature, zoom) -> getStyleFor: (layer, feature, zoom) ->