mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-01 15:50:13 +00:00
Add typings for leaflet-markercluster
This commit is contained in:
19
leaflet-markercluster/leaflet-markercluster-tests.ts
Normal file
19
leaflet-markercluster/leaflet-markercluster-tests.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
/// <reference path="leaflet-markercluster.d.ts" />
|
||||
|
||||
var map: L.Map;
|
||||
var markerClusterGroup: L.MarkerClusterGroup;
|
||||
|
||||
// CircleMarker
|
||||
var circleMarker: L.CircleMarker = new L.CircleMarker(new L.LatLng(0, 0));
|
||||
|
||||
markerClusterGroup.addLayer(circleMarker);
|
||||
map.addLayer(markerClusterGroup);
|
||||
map.removeLayer(markerClusterGroup);
|
||||
|
||||
// Marker
|
||||
var marker = new L.Marker(new L.LatLng(0, 0));
|
||||
|
||||
markerClusterGroup.addLayers([circleMarker, marker]);
|
||||
map.addLayer(markerClusterGroup);
|
||||
markerClusterGroup.refreshClusters();
|
||||
map.removeLayer(markerClusterGroup);
|
||||
125
leaflet-markercluster/leaflet-markercluster.d.ts
vendored
Normal file
125
leaflet-markercluster/leaflet-markercluster.d.ts
vendored
Normal file
@@ -0,0 +1,125 @@
|
||||
// Type definitions for Leaflet.markercluster v0.4.0
|
||||
// Project: https://github.com/Leaflet/Leaflet.markercluster
|
||||
// Definitions by: Robert Imig <https://github.com/rimig>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../leaflet/leaflet.d.ts" />
|
||||
|
||||
declare module L {
|
||||
export interface MarkerClusterGroupOptions {
|
||||
|
||||
/*
|
||||
* When you mouse over a cluster it shows the bounds of its markers.
|
||||
*/
|
||||
showCoverageOnHover?: boolean;
|
||||
|
||||
/*
|
||||
* When you click a cluster we zoom to its bounds.
|
||||
*/
|
||||
zoomToBoundsOnClick?: boolean;
|
||||
|
||||
/*
|
||||
* When you click a cluster at the bottom zoom level we spiderfy it
|
||||
* so you can see all of its markers.
|
||||
*/
|
||||
spiderfyOnMaxZoom?: boolean;
|
||||
|
||||
/*
|
||||
* Clusters and markers too far from the viewport are removed from the map
|
||||
* for performance.
|
||||
*/
|
||||
removeOutsideVisibleBounds?: boolean;
|
||||
|
||||
/*
|
||||
* Smoothly split / merge cluster children when zooming and spiderfying.
|
||||
* If L.DomUtil.TRANSITION is false, this option has no effect (no animation is possible).
|
||||
*/
|
||||
animate?: boolean;
|
||||
|
||||
/*
|
||||
* If set to true (and animate option is also true) then adding individual markers to the
|
||||
* MarkerClusterGroup after it has been added to the map will add the marker and animate it
|
||||
* into the cluster. Defaults to false as this gives better performance when bulk adding markers.
|
||||
* addLayers does not support this, only addLayer with individual Markers.
|
||||
*/
|
||||
animateAddingMarkers?: boolean;
|
||||
|
||||
/*
|
||||
* If set, at this zoom level and below markers will not be clustered. This defaults to disabled.
|
||||
*/
|
||||
disableClusteringAtZoom?: number;
|
||||
|
||||
/*
|
||||
* The maximum radius that a cluster will cover from the central marker (in pixels). Default 80.
|
||||
* Decreasing will make more, smaller clusters.
|
||||
*/
|
||||
maxClusterRadius?: number;
|
||||
|
||||
/*
|
||||
* Options to pass when creating the L.Polygon(points, options) to show the bounds of a cluster.
|
||||
* Defaults to empty
|
||||
*/
|
||||
polygonOptions?: PolylineOptions;
|
||||
|
||||
/*
|
||||
* If set to true, overrides the icon for all added markers to make them appear as a 1 size cluster.
|
||||
*/
|
||||
singleMarkerMode?: boolean;
|
||||
|
||||
/*
|
||||
* Allows you to specify PolylineOptions to style spider legs.
|
||||
* By default, they are { weight: 1.5, color: '#222', opacity: 0.5 }.
|
||||
*/
|
||||
spiderLegPolylineOptions?: PolylineOptions;
|
||||
|
||||
/*
|
||||
* Increase from 1 to increase the distance away from the center that spiderfied markers are placed.
|
||||
* Use if you are using big marker icons (Default: 1).
|
||||
*/
|
||||
spiderfyDistanceMultiplier?: number;
|
||||
|
||||
/*
|
||||
* Function used to create the cluster icon
|
||||
*/
|
||||
iconCreateFunction?: any;
|
||||
}
|
||||
|
||||
export class MarkerClusterGroup extends FeatureGroup<ILayer> {
|
||||
initialize(): void;
|
||||
initialize(options: MarkerClusterGroupOptions): void;
|
||||
|
||||
/*
|
||||
* Bulk methods for adding and removing markers and should be favoured over the
|
||||
* single versions when doing bulk addition/removal of markers.
|
||||
*/
|
||||
addLayers(layers:ILayer[]):MarkerClusterGroup;
|
||||
removeLayers(layers:ILayer[]):MarkerClusterGroup;
|
||||
|
||||
clearLayers():MarkerClusterGroup;
|
||||
|
||||
/*
|
||||
* If you have a marker in your MarkerClusterGroup and you want to get the visible
|
||||
* parent of it
|
||||
*/
|
||||
getVisibleParent(marker: Marker): Marker;
|
||||
|
||||
/*
|
||||
* If you have customized the clusters icon to use some data from the contained markers,
|
||||
* and later that data changes, use this method to force a refresh of the cluster icons.
|
||||
*/
|
||||
refreshClusters():MarkerClusterGroup;
|
||||
refreshClusters(layerGroup:LayerGroup<ILayer>):MarkerClusterGroup;
|
||||
refreshClusters(marker: Marker):MarkerClusterGroup;
|
||||
refreshClusters(markers: Marker[]):MarkerClusterGroup;
|
||||
|
||||
/*
|
||||
* Returns the total number of markers contained within that cluster.
|
||||
*/
|
||||
getChildCount(): number;
|
||||
|
||||
/*
|
||||
* Returns the array of total markers contained within that cluster.
|
||||
*/
|
||||
getAllChildMarkers(): Marker[];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user