Skip to content

xmityaz/react-gmaps

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 {Gmaps, Marker} from 'react-gmaps';

const coords = {
  lat: 51.5258541,
  lng: -0.08040660000006028 
}

const App = React.createClass({

  onMapCreated() {
    console.log('onMapCreated', this.refs.Gmaps.getMap());
    this.refs.Gmaps.getMap().setOptions({
      disableDefaultUI: true
    });
  },

  onClick(e) {
    console.log('onClick', e);
  },

  onDragEnd(e) {
    console.log('onDragEnd', e);
  },

  render() {
    return (
      <Gmaps 
        ref='Gmaps'
        width={'800px'}
        height={'600px'}
        lat={coords.lat} 
        lng={coords.lng} 
        zoom={12} 
        onMapCreated={this.onMapCreated}
        onClick={this.onClick}>
        <Marker 
          lat={coords.lat} 
          lng={coords.lng}
          draggable={true}
          onDragEnd={this.onDragEnd} />
      </Gmaps>
    );
  }

});

React.render(<App />, document.getElementById('gmaps'));

Test

$ npm test

About

A Google Maps component for React.js

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 96.5%
  • HTML 3.5%