From 9ee1c876168ddd8507f7ec4db7f8d262e729dafa Mon Sep 17 00:00:00 2001 From: Arne Schubert Date: Wed, 31 Oct 2018 18:34:04 +0100 Subject: [PATCH] #24044: Style-function as possible input --- types/leaflet/index.d.ts | 6 ++++++ types/leaflet/leaflet-tests.ts | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/types/leaflet/index.d.ts b/types/leaflet/index.d.ts index 8402d8bc9b..a08dcce5ae 100644 --- a/types/leaflet/index.d.ts +++ b/types/leaflet/index.d.ts @@ -919,6 +919,12 @@ export class GeoJSON

extends FeatureGroup

{ */ resetStyle(layer: Layer): Layer; + /** + * Same as FeatureGroup's setStyle method, but style-functions are also + * allowed here to set the style according to the feature. + */ + setStyle(style: PathOptions | StyleFunction

): this; + options: GeoJSONOptions

; } diff --git a/types/leaflet/leaflet-tests.ts b/types/leaflet/leaflet-tests.ts index d1375fa83f..5e8a876774 100644 --- a/types/leaflet/leaflet-tests.ts +++ b/types/leaflet/leaflet-tests.ts @@ -414,6 +414,14 @@ let nestedTwoCoords = [ [12, 13], [13, 14], [14, 15] ]; const nestedLatLngs: L.LatLng[] = L.GeoJSON.coordsToLatLngs(nestedTwoCoords, 1); nestedTwoCoords = L.GeoJSON.latLngsToCoords(nestedLatLngs, 1); +const geojson = new L.GeoJSON(); +const style: L.PathOptions = { + className: "string", +}; +const styler: L.StyleFunction = () => style; +geojson.setStyle(style); +geojson.setStyle(styler); + class MyMarker extends L.Marker { constructor() { super([12, 13]);