mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
Created type definitions for 'leaflet.featuregroup.subgroup' (#37456)
This commit is contained in:
parent
90298b1f8b
commit
0597482b35
48
types/leaflet.featuregroup.subgroup/index.d.ts
vendored
Normal file
48
types/leaflet.featuregroup.subgroup/index.d.ts
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
// Type definitions for leaflet.FeatureGroup.SubGroup 1.0
|
||||
// Project: https://github.com/ghybs/Leaflet.FeatureGroup.SubGroup
|
||||
// Definitions by: Thomas Revesz <https://github.com/drtomato>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
import * as L from 'leaflet';
|
||||
|
||||
declare module 'leaflet' {
|
||||
namespace FeatureGroup {
|
||||
/**
|
||||
* An extended FeatureGroup that adds its child layers into a parent
|
||||
* group when added to a map (e.g., through L.Control.Layers). Typical
|
||||
* usage is to dynamically add and remove groups of markers from marker
|
||||
* clusters.
|
||||
*/
|
||||
class SubGroup<P = any> extends FeatureGroup<P> {
|
||||
/**
|
||||
* Instantiates a SubGroup.
|
||||
*/
|
||||
constructor(parentGroup?: LayerGroup, layers?: Layer[]);
|
||||
|
||||
/**
|
||||
* Changes the parent group into which child markers are added to or
|
||||
* removed from.
|
||||
*/
|
||||
setParentGroup(parentGroup: LayerGroup): this;
|
||||
|
||||
/**
|
||||
* Removes the current sub-group from map before changing the parent
|
||||
* group. Re-adds the sub-group to map if it was before changing.
|
||||
*/
|
||||
setParentGroupSafe(parentGroup: LayerGroup): this;
|
||||
|
||||
/**
|
||||
* Returns the current parent group.
|
||||
*/
|
||||
getParentGroup(): LayerGroup;
|
||||
}
|
||||
}
|
||||
|
||||
namespace featureGroup {
|
||||
/**
|
||||
* Creates a feature subgroup, optionally given an initial parent group and a set of layers.
|
||||
*/
|
||||
function subGroup(parentGroup?: LayerGroup, layers?: Layer[]): FeatureGroup.SubGroup;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,34 @@
|
||||
import * as L from 'leaflet';
|
||||
import 'leaflet.featuregroup.subgroup';
|
||||
|
||||
// Setup
|
||||
interface MyProperties {
|
||||
testProperty: string;
|
||||
}
|
||||
const parentGroup1: L.LayerGroup = L.layerGroup();
|
||||
const latLng: L.LatLng = L.latLng(10, 10);
|
||||
const layer: L.Layer = L.marker(latLng);
|
||||
const layers: L.Layer[] = [layer];
|
||||
|
||||
// Construction using the constructor
|
||||
let subGroup = new L.FeatureGroup.SubGroup<MyProperties>();
|
||||
subGroup = new L.FeatureGroup.SubGroup<MyProperties>(parentGroup1);
|
||||
subGroup = new L.FeatureGroup.SubGroup<MyProperties>(parentGroup1, layers);
|
||||
|
||||
// Construction using the 'leaflet-style' factory method
|
||||
subGroup = L.featureGroup.subGroup();
|
||||
subGroup = L.featureGroup.subGroup(parentGroup1);
|
||||
subGroup = L.featureGroup.subGroup(parentGroup1, layers);
|
||||
|
||||
// Setting and getting the parent group
|
||||
const parentGroup2: L.LayerGroup = L.layerGroup();
|
||||
subGroup.setParentGroup(parentGroup2);
|
||||
subGroup.setParentGroupSafe(parentGroup2);
|
||||
const parentGroup3 = subGroup.getParentGroup();
|
||||
|
||||
// Calling methods inherited from FeatureGroup
|
||||
const bounds: L.LatLngBounds = subGroup
|
||||
.setStyle({})
|
||||
.bringToFront()
|
||||
.bringToBack()
|
||||
.getBounds();
|
||||
24
types/leaflet.featuregroup.subgroup/tsconfig.json
Normal file
24
types/leaflet.featuregroup.subgroup/tsconfig.json
Normal file
@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"leaflet.featuregroup.subgroup-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/leaflet.featuregroup.subgroup/tslint.json
Normal file
1
types/leaflet.featuregroup.subgroup/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user