mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
Merge pull request #23697 from nenadvicentic/master
`MarkerCluster` and `MarkerClusterGroup` should be classes
This commit is contained in:
commit
a3d43a68ee
4
types/leaflet.markercluster/index.d.ts
vendored
4
types/leaflet.markercluster/index.d.ts
vendored
@ -7,7 +7,7 @@
|
||||
import * as L from 'leaflet';
|
||||
|
||||
declare module 'leaflet' {
|
||||
interface MarkerCluster extends Marker {
|
||||
class MarkerCluster extends Marker {
|
||||
/*
|
||||
* Recursively retrieve all child markers of this cluster.
|
||||
*/
|
||||
@ -117,7 +117,7 @@ declare module 'leaflet' {
|
||||
chunkDelay?: number;
|
||||
}
|
||||
|
||||
interface MarkerClusterGroup extends FeatureGroup {
|
||||
class MarkerClusterGroup extends FeatureGroup {
|
||||
/*
|
||||
* Bulk methods for adding and removing markers and should be favoured over the
|
||||
* single versions when doing bulk addition/removal of markers.
|
||||
|
||||
@ -81,3 +81,34 @@ markerClusterGroup.zoomToShowLayer(marker, () => {});
|
||||
let hasLayer: boolean;
|
||||
hasLayer = markerClusterGroup.hasLayer(layer);
|
||||
hasLayer = markerClusterGroup.hasLayer(marker);
|
||||
|
||||
// inheritance
|
||||
const Subclass1 = L.MarkerClusterGroup.extend({
|
||||
myFunction() {}
|
||||
});
|
||||
class Subclass2 extends L.MarkerClusterGroup {
|
||||
myFunction() {}
|
||||
}
|
||||
const Subclass3 = L.MarkerCluster.extend({
|
||||
myFunction() {}
|
||||
});
|
||||
class Subclass4 extends L.MarkerCluster {
|
||||
myFunction() {}
|
||||
}
|
||||
|
||||
const s1 = new Subclass1(); // any
|
||||
const s2 = new Subclass2();
|
||||
const s3 = new Subclass3(); // any
|
||||
const s4 = new Subclass4([1, 2]);
|
||||
|
||||
// call subclass function
|
||||
s1.myFunction();
|
||||
s2.myFunction();
|
||||
s3.myFunction();
|
||||
s4.myFunction();
|
||||
|
||||
// call base class function
|
||||
s1.refreshClusters();
|
||||
s2.refreshClusters();
|
||||
s3.getAllChildMarkers();
|
||||
s4.getAllChildMarkers();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user