diff --git a/types/leaflet.gridlayer.googlemutant/index.d.ts b/types/leaflet.gridlayer.googlemutant/index.d.ts index 29a1e69a6b..a9d0c943f4 100644 --- a/types/leaflet.gridlayer.googlemutant/index.d.ts +++ b/types/leaflet.gridlayer.googlemutant/index.d.ts @@ -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; + + /** + * 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'; diff --git a/types/leaflet.gridlayer.googlemutant/leaflet.gridlayer.googlemutant-tests.ts b/types/leaflet.gridlayer.googlemutant/leaflet.gridlayer.googlemutant-tests.ts index 6bda5d2a5d..8face8c3f8 100644 --- a/types/leaflet.gridlayer.googlemutant/leaflet.gridlayer.googlemutant-tests.ts +++ b/types/leaflet.gridlayer.googlemutant/leaflet.gridlayer.googlemutant-tests.ts @@ -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'); +});