# react-leaflet-google-layer

> React leaflet wrapper of leaflet.gridlayer.googlemutant

Latest version **4.0.0** (published 2025-02-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-leaflet-google-layer
pnpm add react-leaflet-google-layer
yarn add react-leaflet-google-layer
bun add react-leaflet-google-layer
```

## Health

**Score 45/100 (D)** — status: stable.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 4.0.0 |
| Published | 2025-02-22 |
| First published | 2019-03-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 12.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 53 |
| Maintainers | avikl |
| Keywords | React, Leaflet, google, googlemutant, typescript, react-leaflet-v3, react-leaflet-v4 |

## Links

- npm: https://www.npmjs.com/package/react-leaflet-google-layer
- Repository: https://github.com/aviklai/react-leaflet-google-layer
- Homepage: https://github.com/aviklai/react-leaflet-google-layer#readme
- Issues: https://github.com/aviklai/react-leaflet-google-layer/issues
- npm.io page: https://npm.io/package/react-leaflet-google-layer

## Dependencies (4)

- [@types/leaflet](https://npm.io/package/@types/leaflet.md) ^1.5.0
- [@googlemaps/js-api-loader](https://npm.io/package/@googlemaps/js-api-loader.md) ^1.8.0
- [leaflet.gridlayer.googlemutant](https://npm.io/package/leaflet.gridlayer.googlemutant.md) ^0.15.0
- [@types/leaflet.gridlayer.googlemutant](https://npm.io/package/@types/leaflet.gridlayer.googlemutant.md) ^0.4.9

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 4.0.0 (latest) — 2025-02-22
- 1.1.6 (v1-mutant-fix) — 2022-02-17
- 3.1.0 — 2025-01-22
- 3.0.0 — 2024-12-10
- 2.2.0 — 2022-12-29
- 2.1.0 — 2022-12-29
- 2.0.7 — 2022-07-01
- 2.0.6 — 2022-06-02
- 2.0.5 — 2022-02-17
- 2.0.4 — 2021-05-12
- 2.0.3 — 2020-11-09
- 2.0.2 — 2020-11-09
- 2.0.1 — 2020-11-09
- 2.0.0 — 2020-11-06
- 1.1.5 — 2020-10-13
- … 19 more at https://npm.io/package/react-leaflet-google-layer/versions

## README

[![Build Status](https://github.com/aviklai/react-leaflet-google-layer/actions/workflows/ci.yml/badge.svg)](https://github.com/aviklai/react-leaflet-google-layer/actions/workflows/ci.yml) 
[![Coverage Status](https://coveralls.io/repos/github/aviklai/react-leaflet-google-layer/badge.svg?branch=master)](https://coveralls.io/github/aviklai/react-leaflet-google-layer?branch=master) 
[![npm version](https://img.shields.io/npm/v/react-leaflet-google-layer.svg)](https://www.npmjs.com/package/react-leaflet-google-layer)

Google layer for React Leaflet v3 and v4 using leaflet.gridlayer.googlemutant, implemented with typescript.

## Requirements
The current version of this library supports React Leaflet v3 and v4. <br/>
If you are using React Leaflet v2, please use the previous version of this library. Please see the documentation here: <br/>
https://github.com/aviklai/react-leaflet-google-layer/tree/v1

## Installation instructions:
1. run `npm install --save react-leaflet-google-layer`
2. By default this library uses the google-maps loader library to load the google maps api. If you want to use the script tag instead, you can Add google maps js api in your index.html: <br/> 
`<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY" async defer></script>` <br/>
and set the prop useGoogMapsLoader to `false`.


Usage example:
```
import * as React from 'react';
import { MapContainer } from 'react-leaflet';
import ReactLeafletGoogleLayer from 'react-leaflet-google-layer';

export const App = () => { 
  return (
      <MapContainer zoom={15} center={[45, 20]}>
        <ReactLeafletGoogleLayer apiKey='YOUR_API_KEY' type={'satellite'} />
      </MapContainer>
  );
};

```

## Basic usage example
https://codesandbox.io/s/basic-usage-with-react-leaflet-v3-vx8fd

## Options
apiKey?: string <br/>
useGoogMapsLoader?: boolean, default: `true` <br/>
googleMapsAddLayers?: { name: 'BicyclingLayer' | 'TrafficLayer' | 'TransitLayer', options?: any }[] <br/>
zIndex?: number <br/>

#### From js-api-loader (https://github.com/googlemaps/js-api-loader) - googleMapsLoaderConf prop:
* version?: string
* client?: string
* channel?: string
* language?: string
* region?: string
* libraries?: string[]

#### From googlemutant (https://gitlab.com/IvanSanchez/Leaflet.GridLayer.GoogleMutant):
* minZoom?: number
* maxZoom?: number
* maxNativeZoom?: number
* tileSize?: number | Point
* subdomains?: string | string[]
* errorTileUrl?: string
* attribution?: string
* opacity?: number
* continuousWorld?: boolean
* noWrap?: boolean
* type?: 'roadmap' | 'satellite' | 'terrain' | 'hybrid'
* styles?: GoogleMutantStyle[]

---
_Source: https://npm.io/package/react-leaflet-google-layer · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
