diff --git a/docs/vectorgrid-api-docs.html b/docs/vectorgrid-api-docs.html index 7828a53..ebbb2bb 100644 --- a/docs/vectorgrid-api-docs.html +++ b/docs/vectorgrid-api-docs.html @@ -366,7 +366,7 @@

Methods

var vectorTileOptions = {
     vectorTileLayerStyles: {
         // A plain set of L.Path options.
-        water: {
+        landuse: {
             weight: 0,
             fillColor: '#9bc2c4',
             fillOpacity: 1,
@@ -385,6 +385,35 @@ 

Methods

fillOpacity: 0 } }, + // A function for styling features dynamically, depending on their + // properties, the map's zoom level, and the layer's geometry + // dimension (point, line, polygon) + water: function(properties, zoom, geometryDimension) { + if (geometryDimension === 1) { // point + return ({ + radius: 5, + color: '#cf52d3', + }); + } + + if (geometryDimension === 2) { // line + return ({ + weight: 1, + color: '#cf52d3', + dashArray: '2, 6', + fillOpacity: 0 + }); + } + + if (geometryDimension === 3) { // polygon + return ({ + weight: 1, + fillColor: '#9bc2c4', + fillOpacity: 1, + fill: true + }); + } + }, // An 'icon' option means that a L.Icon will be used place: { icon: new L.Icon.Default() @@ -399,7 +428,7 @@

Methods

  • A set of L.Path options
  • An array of sets of L.Path options
  • A function that returns a set of L.Path options
  • -
  • A function that returns an array of sets of L.Path options +
  • A function that returns an array of sets of L.Path options for point, line, and polygon styles respectively
    Layers² with no style specified will use the default L.Path options.
    diff --git a/src/Leaflet.VectorGrid.js b/src/Leaflet.VectorGrid.js index 1aa3eab..4a538cf 100644 --- a/src/Leaflet.VectorGrid.js +++ b/src/Leaflet.VectorGrid.js @@ -95,7 +95,7 @@ L.VectorGrid = L.GridLayer.extend({ } if (styleOptions instanceof Function) { - styleOptions = styleOptions(feat.properties, coords.z); + styleOptions = styleOptions(feat.properties, coords.z, feat.type); } if (!(styleOptions instanceof Array)) { @@ -188,7 +188,7 @@ L.VectorGrid = L.GridLayer.extend({ _updateStyles: function(feat, renderer, styleOptions) { styleOptions = (styleOptions instanceof Function) ? - styleOptions(feat.properties, renderer.getCoord().z) : + styleOptions(feat.properties, renderer.getCoord().z, feat.type) : styleOptions; if (!(styleOptions instanceof Array)) {