#24044: Style-function as possible input

This commit is contained in:
Arne Schubert 2018-10-31 18:34:04 +01:00
parent 549360d30e
commit 9ee1c87616
2 changed files with 14 additions and 0 deletions

View File

@ -919,6 +919,12 @@ export class GeoJSON<P = any> extends FeatureGroup<P> {
*/
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<P>): this;
options: GeoJSONOptions<P>;
}

View File

@ -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<MyProperties> = () => style;
geojson.setStyle(style);
geojson.setStyle(styler);
class MyMarker extends L.Marker {
constructor() {
super([12, 13]);