React components that make it easy to add Google maps and markers to your React projects.
Via npm
npm install --save react-maps-googleVia Yarn
yarn add react-maps-googleThis package includes the core GoogleMap component that renders a Google Map
into your React project. Along with Marker and MarkerClusterer components that
make it easy to compose markers into your map instances.
apiKey:StringRequired - Google Maps Javascript API key. Guide to get an API keyasync:Bool- True loads Google Maps script asynchronously. Defaults to true.options:Object- Options for customizing/styling the map. MapOptions InterfaceonReady:Function- Called when the Google Maps script has initialized(map) => {}onBoundsChange:Function- Called when thebounds_changedevent is fired from the map.(map) => {}onCenterChange:Function- Called when thechange_changedevent is fired from the map.(map) => {}onClick:Function- Called when theclickevent is fired from the map.(map, event) => {}onDoubleClick:Function- Called when thedblclickevent is fired from the map.(map, event) => {}onDrag:Function- Called when thedragevent is fired from the map.(map) => {}onDragEnd:Function- Called when thedragendevent is fired from the map.(map) => {}onDragStart:Function- Called when thedragstartevent is fired from the map.(map) => {}onHeadingChange:Function- Called when theheading_changedevent is fired from the map.(map) => {}onIdle:Function- Called when theidleevent is fired from the map.(map) => {}onMapTypeIdChange:Function- Called when themaptypeid_changedevent is fired from the map.(map) => {}onMouseMove:Function- Called when themousemoveevent is fired from the map.(map, event) => {}onMouseOut:Function- Called when themouseoutevent is fired from the map.(map, event) => {}onMouseOver:Function- Called when themouseoverevent is fired from the map.(map, event) => {}onProjectionChange:Function- Called when theprojection_changedevent is fired from the map.(map) => {}onRightClick:Function- Called when therightclickevent is fired from the map.(map, event) => {}onTilesLoad:Function- Called when thetilesloadedevent is fired from the map.(map) => {}onTiltChange:Function- Called when thetilt_changedevent is fired from the map.(map) => {}onZoomChange:Function- Called when thezoom_changedevent is fired from the map.(map) => {}
All callbacks return a reference to the google.maps.Map instance rendered within the
component and the associated Event (where supported).
import React from 'react';
import GoogleMap, { Marker } from 'react-maps-google';
const ExampleMap = (props) => {
  return (
    <GoogleMap apiKey="[insert your api key here]">
      <Marker position={{lat: 40.7174343, lng: -73.9930319}} />
    </GoogleMap>
  );
}position:ObjectRequired - The latitude and longitude coordinates to render the marker.{{lat: 0, lng: 0}}map:Object- Reference the to thegoogle.maps.Mapinstance, passed to the component withinGoogleMap.options:Object- Options for customizing/styling the marker. MarkerOptions InterfaceonAnimationChange:Function- Called when theanimation_changedevent is fired from the marker.(marker) => {}onClick:Function- Called when theclickevent is fired from the marker.(marker, event) => {}onClickkableChange:Function- Called when theclickable_changedevent is fired from the marker.(marker) => {}onCursorChange:Function- Called when thecursor_changedevent is fired from the marker.(marker) => {}onDoubleClick:Function- Called when thedblclickevent is fired from the marker.(marker, event) => {}onDrag:Function- Called when thedragevent is fired from the marker.(marker, event) => {}onDragEnd:Function- Called when thedragendevent is fired from the marker.(marker, event) => {}onDraggableChange:Function- Called when thedraggable_changedevent is fired from the marker.(marker) => {}onDragStart:Function- Called when thedragstartevent is fired from the marker.(marker, event) => {}onFlatChange:Function- Called when theflat_changedevent is fired from the marker.(marker) => {}onIconChange:Function- Called when theicon_changedevent is fired from the marker.(marker) => {}onMouseDown:Function- Called when themousedownevent is fired from the marker.(marker, event) => {}onMouseOut:Function- Called when themouseoutevent is fired from the marker.(marker, event) => {}onMouseOver:Function- Called when themouseoverevent is fired from the marker.(marker, event) => {}onMouseUp:Function- Called when themouseupevent is fired from the marker.(marker, event) => {}onPositionChange:Function- Called when theposition_changedevent is fired from the marker.(marker) => {}onRightClick:Function- Called when therightclickevent is fired from the marker.(marker, event) => {}onShapeChange:Function- Called when theshape_changedevent is fired from the marker.(marker) => {}onTitleChange:Function- Called when thetitle_changedevent is fired from the marker.(marker) => {}onVisibleChange:Function- Called when thevisible_changedevent is fired from the marker.(marker) => {}onZIndexChange:Function- Called when thezindex_changedevent is fired from the marker.(marker) => {}
import React, { Component } from 'react';
import GoogleMap, { Marker } from 'react-maps-google';
class ExampleMap extends Component {
  constructor(props) {
    super(props);
    this.onMarkerClick = this.onMarkerClick.bind(this);
  }
  onMarkerClick(marker, event) {
  }
  render() {
    return (
      <GoogleMap apiKey="[insert your api key here]">
        <Marker
          position={{lat: 40.7174343, lng: -73.9930319}}
          onClick={this.onMarkerClick}
        />
      </GoogleMap>
    );
  }
}[in development]
MIT ยฉ Ryan Hefner