[@types/leaflet.gridlayer.googlemutant] add GoogleLayer methods to GoogleMutant interface (#42389)

* addGoogleLayer and removeGoogleLayer

* prettier
This commit is contained in:
Ryan Morris
2020-02-21 14:03:09 -06:00
committed by GitHub
parent 13a134561d
commit a0baa6bde3
2 changed files with 39 additions and 11 deletions

View File

@@ -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';

View File

@@ -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');
});