Skip to content

opuslabs/react-google-map

 
 

Repository files navigation

react-google-map npm license

React component to render a map with markers from Google Maps API

react-google-map example

Install

npm install --save react-google-map

Changelog

See changelog

Demo

http://cedricdelpoux.github.io/react-google-map/

Usage

import React, { Component } from 'react'
import GoogleMap from 'react-google-map'

export default class MyComponent extends Component {
  state = {
    coordinates: [],
    zoom: 8,
  }

  handleMapChange(coordinates, zoom) {
      this.setState({ coordinates, zoom })
    }

  render() {
    const { coordinates, zoom } = this.state

    return (
      <GoogleMap
        coordinates={ coordinates }
        zoom={ zoom }
        onChange={ (coordinates, zoom) => this.handleMapChange(coordinates, zoom) }
      />
    )
  }
}

Props

  • coordinates: Array of objects with shape { description: String, latitude: Number, longitude: Number, title: String } - by default is []
  • defaultLat: Number,
  • defaultLng: Number,
  • googleMaps: Object - injected by decorator,
  • onChange: Function with two parameters (New coordinates object, actual zoom),
  • zoom: Number - isRequired,

Classes

  • .googleMap

Development

Clean lib folder

npm run clean

Build lib folder

npm run build

Watch src folder

npm run watch

Lint src folder

npm run lint

License

See MIT

About

React component to render a map with markers from Google Maps API

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 96.9%
  • CSS 3.1%