# react-js-google-maps

> Simple google maps for React.Js

Latest version **1.5.2** (published 2018-01-06) · ISC license · 0 weekly downloads

## Install

```sh
npm install react-js-google-maps
pnpm add react-js-google-maps
yarn add react-js-google-maps
bun add react-js-google-maps
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.5.2 |
| Published | 2018-01-06 |
| First published | 2017-11-11 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Cuneyt Aliustaoglu |
| Maintainers | aliustaoglu |
| Keywords | react, google, maps |

## Links

- npm: https://www.npmjs.com/package/react-js-google-maps
- Repository: https://github.com/aliustaoglu/react-js-google-maps
- Homepage: https://github.com/aliustaoglu/react-js-google-maps#readme
- Issues: https://github.com/aliustaoglu/react-js-google-maps/issues
- npm.io page: https://npm.io/package/react-js-google-maps

## 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

- 1.5.2 (latest) — 2018-01-06
- 1.5.1 — 2017-12-11
- 1.5.0 — 2017-12-10
- 1.0.9 — 2017-11-11
- 1.0.8 — 2017-11-11
- 1.0.7 — 2017-11-11
- 1.0.6 — 2017-11-11
- 1.0.5 — 2017-11-11
- 1.0.4 — 2017-11-11
- 1.0.3 — 2017-11-11
- 1.0.2 — 2017-11-11
- 1.0.1 — 2017-11-11
- 1.0.0 — 2017-11-11

## README

![react-js-google-maps](https://raw.githubusercontent.com/aliustaoglu/react-js-google-maps/master/img/react-js-google-maps.png)

# React Js Google Maps
Lazy loading Google Maps API Wrapper for React.JS. 

# [Click For the Online Demo](https://stackblitz.com/edit/react-ohakbs?embed=1&file=index.js)

All I needed was a simple React component that initiates Google Maps API without any dependencies other than React or Google. I want is to pass my props to my component and handle the rest with the Google API. So I wrote this simple library.

The component needs an id for the div that will wrap the canvas object created by Google Maps API. mapOptions is the object that you normally pass onto google while you're creating a new map. It will also need some styling(either style or className) for this div. That's all. The rest we will do with the Google API.

Prop Types
```json
{
    id: PropTypes.string.isRequired,
    apiKey: PropTypes.string.isRequired,
    mapOptions: PropTypes.object,
    className: PropTypes.string,
    style: PropTypes.object
}
```

Usage is simple:
```js
import React, { Component } from 'react';
import Map from 'react-js-google-maps';

const setMarker = () => {
  var uluru = { lat: -25.363, lng: 131.044 };
  var marker = new window.google.maps.Marker({
    position: uluru,
    map: window.gmaps['map1'].gmap
  });
};

/*
May be Some react code here
*/
render() {
  const mapOptions = {
    zoom: 4,
    center: { lat: -25.363, lng: 131.044 }
  }
  // You can make API calls to load your data into the map
  // after the map is initialized
  onMapLoad() {
    setMarker();
  }
  return (
    <div>
      <Map
        id="map1"
        apiKey="MY_API_KEY"
        mapOptions={mapOptions}
        style={{ width: '100%', height: 480 }}
        onLoad={this.onMapLoad}
      />
    </div>
  );
}

```

# Version History:
No history info until 1.5.1
1.5.2: Added onLoad prop to trigger a custom event when the map is ready.

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