Coder Social home page Coder Social logo

z-react / react-google-maps Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tomchentw/react-google-maps

0.0 2.0 0.0 9.03 MB

React.js Google Maps integration component

Home Page: https://tomchentw.github.io/react-google-maps/

License: MIT License

JavaScript 97.50% HTML 2.23% CSS 0.27%

react-google-maps's Introduction

react-google-maps

React.js Google Maps integration component

Version Travis CI Quality Coverage Dependencies Gitter

Under development for v6.0.0

Try it via:

npm install --save react-google-maps@beta

Call for maintainers

As the author (tomchentw) currently doesn't actively use this module, he's looking for awesome contributors to help and keep the community healthy. Please don't hesitate to contact him directly. See #266 for more information.

Documentation

Basically just a simple wrapper around Google Maps Javascript API. Also check out the demo app and it's source under src/app folder.

Note: this doc is under development for v6.0.0. Find docs for v5.x and v4.x with the git tags.

withGoogleMap

import { withGoogleMap } from "react-google-maps";

// Wrap all `react-google-maps` components with `withGoogleMap` HOC
// and name it GettingStartedGoogleMap
const GettingStartedGoogleMap = withGoogleMap(props => (
  <GoogleMap
    ref={props.onMapLoad}
    defaultZoom={3}
    defaultCenter={{ lat: -25.363882, lng: 131.044922 }}
    onClick={props.onMapClick}
  >
    {props.markers.map((marker, index) => (
      <Marker
        {...marker}
        onRightClick={() => props.onMarkerRightClick(index)}
      />
    ))}
  </GoogleMap>
));
// Then, render it:
render(
  <GettingStartedGoogleMap
    containerElement={
      <div style={{ height: `100%` }} />
    }
    mapElement={
      <div style={{ height: `100%` }} />
    }
    onMapLoad={_.noop}
    onMapClick={_.noop}
    markers={markers}
    onMarkerRightClick={_.noop}
  />,
  document.getElementById('root')
);

GoogleMap

<GoogleMap
  onClick={_.noop}
  onRightClick={_.noop}
  onDragStart={_.noop}
/>

Marker

<Marker
  onClick={_.noop}
  onRightClick={_.noop}
  onDragStart={_.noop}
/>

Circle

<Circle
  onClick={_.noop}
  onRightClick={_.noop}
  onDragStart={_.noop}
/>

Rectangle

<Rectangle
  onClick={_.noop}
  onRightClick={_.noop}
  onDragStart={_.noop}
/>

Polyline

<Polyline
  onClick={_.noop}
  onRightClick={_.noop}
  onDragStart={_.noop}
/>

Polygon

<Polygon
  onClick={_.noop}
  onRightClick={_.noop}
  onDragStart={_.noop}
/>

KmlLayer

<KmlLayer
  onClick={_.noop}
  onDefaultViewportChanged={_.noop}
  onStatusChanged={_.noop}
/>

InfoWindow

<InfoWindow
  onCloseClick={_.noop}
  onDomReady={_.noop}
  onZIndexChanged={_.noop}
/>

drawing/DrawingManager

<DrawingManager
  onCircleComplete={_.noop}
  onOverlayComplete={_.noop}
/>

places/SearchBox

<SearchBox
  inputPlaceholder="Customized your placeholder"
  inputStyle={INPUT_STYLE}
/>

addons/MarkerClusterer

<MarkerClusterer
  onClusteringBegin={_.noop}
  onMouseOut={_.noop}
/>

addons/InfoBox

<InfoBox
  onCloseClick={_.noop}
  onDomReady={_.noop}
  onZIndexChanged={_.noop}
/>

async/withScriptjs

import { withGoogleMap } from "react-google-maps";
import withScriptjs from "react-google-maps/lib/async/withScriptjs";

// Wrap all `react-google-maps` components with `withGoogleMap` HOC
// then wraps it into `withScriptjs` HOC
// It loads Google Maps JavaScript API v3 for you asynchronously.
// Name the component AsyncGettingStartedExampleGoogleMap
const AsyncGettingStartedExampleGoogleMap = withScriptjs(
  withGoogleMap(
    props => (
    <GoogleMap
      ref={props.onMapLoad}
      defaultZoom={3}
      defaultCenter={{ lat: -25.363882, lng: 131.044922 }}
      onClick={props.onMapClick}
    >
      {props.markers.map(marker => (
        <Marker
          {...marker}
          onRightClick={() => props.onMarkerRightClick(marker)}
        />
      ))}
    </GoogleMap>
  )
);
// Then, render it:
render(
  <AsyncGettingStartedExampleGoogleMap
    googleMapURL="https://maps.googleapis.com/maps/api/js?v=3.exp"
    loadingElement={
      <div style={{ height: `100%` }}>
        <FaSpinner
          style={{
            display: `block`,
            width: `80px`,
            height: `80px`,
            margin: `150px auto`,
            animation: `fa-spin 2s infinite linear`,
          }}
        />
      </div>
    }
    containerElement={
      <div style={{ height: `100%` }} />
    }
    mapElement={
      <div style={{ height: `100%` }} />
    }
    onMapLoad={_.noop}
    onMapClick={_.noop}
    markers={markers}
    onMarkerRightClick={_.noop}
  />,
  document.getElementById('root')
);

Changelog

The changelog is automatically generated via conventional-changelog and can be found in project root as well as npm tarball.

react-google-maps's People

Contributors

alexishevia avatar amitkothari avatar appleboy avatar beefancohen avatar benwiley4000 avatar bradestey avatar chentsulin avatar danielroth avatar eagleeye avatar emilecantin avatar eyebraus avatar farrrr avatar gpbl avatar heedster avatar idolize avatar idolizesc avatar joshburgess avatar melindabernrdo avatar michalkozminski avatar miroslavpetrik avatar pirate avatar rewop avatar tomchentw avatar urikphytech avatar vjocw avatar wuct avatar ydogandjiev avatar yhsiang avatar ziad-saab avatar zolrath avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.