diff --git a/src/Leaflet.VectorGrid.js b/src/Leaflet.VectorGrid.js index 1aa3eab..2b4bf6b 100644 --- a/src/Leaflet.VectorGrid.js +++ b/src/Leaflet.VectorGrid.js @@ -109,7 +109,12 @@ L.VectorGrid = L.GridLayer.extend({ var featureLayer = this._createLayer(feat, pxPerExtent); for (var j = 0; j < styleOptions.length; j++) { - var style = L.extend({}, L.Path.prototype.options, styleOptions[j]); + if (styleOptions[j] instanceof Function) { + var styleOption = styleOptions[j](feat.properties, coords.z, feat.type); + } else { + var styleOption = styleOptions[j]; + } + var style = L.extend({}, L.Path.prototype.options, styleOption); featureLayer.render(renderer, style); renderer._addPath(featureLayer); } @@ -196,7 +201,10 @@ L.VectorGrid = L.GridLayer.extend({ } for (var j = 0; j < styleOptions.length; j++) { - var style = L.extend({}, L.Path.prototype.options, styleOptions[j]); + var styleOption = (styleOptions[j] instanceof Function) ? + styleOptions[j](feat.properties, renderer.getCoord().z, feat.type) : + styleOptions[j]; + var style = L.extend({}, L.Path.prototype.options, styleOption); feat.updateStyle(renderer, style); } },