ryanhefner / react-maps-google

🗺 React components that make it easy to add Google maps and markers to your React projects.
https://www.pkgstats.com/pkg:react-maps-google
MIT License
4 stars 1 forks source link
google-maps google-maps-api google-maps-markers-list react react-component

🗺 react-maps-google

npm NPM npm Coveralls github CircleCI Snyk Vulnerabilities for GitHub Repo

React components that make it easy to add Google maps and markers to your React projects.

Install

Via npm

npm install --save react-maps-google

Via Yarn

yarn add react-maps-google

How to use

This 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.

<GoogleMap /> Component

Properties

All callbacks return a reference to the google.maps.Map instance rendered within the component and the associated Event (where supported).

Example

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>
  );
}

<Marker /> Component

Properties

Example

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>
    );
  }
}

<MarkerClusterer /> Component

[in development]

License

MIT © Ryan Hefner