mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-08 03:00:02 +00:00
[@types/leaflet.gridlayer.googlemutant] add GoogleLayer methods to GoogleMutant interface (#42389)
* addGoogleLayer and removeGoogleLayer * prettier
This commit is contained in:
22
types/leaflet.gridlayer.googlemutant/index.d.ts
vendored
22
types/leaflet.gridlayer.googlemutant/index.d.ts
vendored
@@ -9,7 +9,27 @@ import * as L from 'leaflet';
|
||||
declare module 'leaflet' {
|
||||
namespace gridLayer {
|
||||
interface GoogleMutant extends GridLayer {
|
||||
setElementSize(e: HTMLElement, size: Point): void ;
|
||||
setElementSize(e: HTMLElement, size: Point): void;
|
||||
|
||||
/**
|
||||
* Add additional Google Maps layer.
|
||||
*
|
||||
* https://developers.google.com/maps/documentation/javascript/trafficlayer
|
||||
*
|
||||
* @param googleLayerName such as BicyclingLayer, TrafficLayer, or TransitLayer.
|
||||
* @param options? constructor arguments to pass through to the google layer.
|
||||
* @returns Promise for the native Google Maps Layer instance.
|
||||
*/
|
||||
addGoogleLayer(googleLayerName: string, options?: object): Promise<object>;
|
||||
|
||||
/**
|
||||
* Removes Google Maps layer.
|
||||
*
|
||||
* https://developers.google.com/maps/documentation/javascript/trafficlayer
|
||||
*
|
||||
* @param googleLayerName such as BicyclingLayer, TrafficLayer, or TransitLayer.
|
||||
*/
|
||||
removeGoogleLayer(googleLayerName: string): void;
|
||||
}
|
||||
|
||||
type GoogleMutantType = 'roadmap' | 'satellite' | 'terrain' | 'hybrid';
|
||||
|
||||
@@ -3,14 +3,22 @@ import 'leaflet.gridlayer.googlemutant';
|
||||
|
||||
const map = L.map('foo');
|
||||
|
||||
const roads = L.gridLayer.googleMutant({
|
||||
type: 'roadmap'
|
||||
}).addTo(map);
|
||||
const roads = L.gridLayer
|
||||
.googleMutant({
|
||||
type: 'roadmap',
|
||||
})
|
||||
.addTo(map);
|
||||
|
||||
const styled = L.gridLayer.googleMutant({
|
||||
type: 'satellite',
|
||||
styles: [
|
||||
{ elementType: 'labels', stylers: [ { visibility: 'off' } ] },
|
||||
{ featureType: 'water' , stylers: [ { color: '#444444' } ] }
|
||||
]
|
||||
}).addTo(map);
|
||||
const styled = L.gridLayer
|
||||
.googleMutant({
|
||||
type: 'satellite',
|
||||
styles: [
|
||||
{ elementType: 'labels', stylers: [{ visibility: 'off' }] },
|
||||
{ featureType: 'water', stylers: [{ color: '#444444' }] },
|
||||
],
|
||||
})
|
||||
.addTo(map);
|
||||
|
||||
styled.addGoogleLayer('TrafficLayer').then(nativeTrafficLayer => {
|
||||
styled.removeGoogleLayer('TrafficLayer');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user