react-gmaps

1.9.0 • Public • Published

Build Status

React Gmaps

A Google Maps component for React.js

Features

  • Lazy Google Maps loading
  • Easy to use

Installation

$ npm install react-gmaps --save

Demo

http://react-gmaps.herokuapp.com/

Usage

import React from 'react';
import ReactDOM from 'react-dom';
import {Gmaps, Marker, InfoWindow, Circle} from 'react-gmaps';
 
const coords = {
  lat: 51.5258541,
  lng: -0.08040660000006028
};
 
const params = {v: '3.exp', key: 'YOUR_API_KEY'};
 
class App extends React.Component {
 
  onMapCreated(map) {
    map.setOptions({
      disableDefaultUI: true
    });
  }
 
  onDragEnd(e) {
    console.log('onDragEnd', e);
  }
 
  onCloseClick() {
    console.log('onCloseClick');
  }
 
  onClick(e) {
    console.log('onClick', e);
  }
 
  render() {
    return (
      <Gmaps
        width={'800px'}
        height={'600px'}
        lat={coords.lat}
        lng={coords.lng}
        zoom={12}
        loadingMessage={'Be happy'}
        params={params}
        onMapCreated={this.onMapCreated}>
        <Marker
          lat={coords.lat}
          lng={coords.lng}
          draggable={true}
          onDragEnd={this.onDragEnd} />
        <InfoWindow
          lat={coords.lat}
          lng={coords.lng}
          content={'Hello, React :)'}
          onCloseClick={this.onCloseClick} />
        <Circle
          lat={coords.lat}
          lng={coords.lng}
          radius={500}
          onClick={this.onClick} />
      </Gmaps>
    );
  }
 
};
 
ReactDOM.render(<App />, document.getElementById('gmaps'));

Test

$ npm test

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.9.01,213latest
2.0.0-next.00next

Version History

VersionDownloads (Last 7 Days)Published
2.0.0-next.00
1.9.01,213
1.8.00
1.7.029
1.6.07
1.5.035
2.0.0-rc40
2.0.0-rc30
2.0.0-rc20
2.0.0-rc10
1.4.40
1.4.30
1.4.20
1.4.10
1.4.00
1.3.00
1.2.20
1.2.10
1.2.00
1.1.00
1.0.40
1.0.30
1.0.20
1.0.10
0.4.20
0.4.10
0.4.00
0.3.40
0.3.30
0.3.20
0.3.10
0.3.00
0.2.00
0.1.130
0.1.120
0.1.110
0.1.100
0.1.90
0.1.80
0.1.70
0.1.60
0.1.50
0.1.40
0.1.30
0.1.20
0.1.10
0.1.00

Package Sidebar

Install

npm i react-gmaps

Weekly Downloads

1,104

Version

1.9.0

License

MIT

Unpacked Size

150 kB

Total Files

23

Last publish

Collaborators

  • michelebertoli