Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow functions in array returned by style function #129

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
12 changes: 10 additions & 2 deletions src/Leaflet.VectorGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
},
Expand Down