Socket
Socket
Sign inDemoInstall

react-maps-loader

Package Overview
Dependencies
8
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-maps-loader

Easily load and consume Google's Maps JavaScript API


Version published
Weekly downloads
2
Maintainers
1
Install size
3.39 MB
Created
Weekly downloads
 

Changelog

Source

0.2.2 (2018-10-29)

Bug Fixes

  • target es5 and expose module (5fa1404)

<a name="0.2.1"></a>

Readme

Source

React Maps Loader

Easily load and consume Google's Maps JavaScript API.

Usage

This library exports a Provider that will load the API for you and put it on the window. You'd probably want to use it somewhere around the root of your app, like so:

import { MapsProvider } from 'react-maps-loader';

import App from './App'; // your beautiful app!

const Root = () => (
  <MapsProvider apiKey="YOUR_API_KEY" libraries={['places']}>
    <App />
  </MapsProvider>
);

Somewhere nested inside the App component, you may have consumers that get the google.maps prop like so:

import { MapsConsumer } from 'react-maps-loader';

import EmbeddedMap from './EmbeddedMap';
import MapContainer from './MapContainer';

const Map = ({ place }) => (
  <MapsConsumer>
    {maps =>
      maps ? (
        <EmbeddedMap
          containerElement={<MapContainer />}
          loadingElement={<div style={{ height: '100%' }} />}
          mapElement={<div style={{ height: '100%' }} />}
          place={place}
        />
      ) : (
        <div>Loading!</div>
      )
    }
  </MapsConsumer>
);

Keywords

FAQs

Last updated on 29 Oct 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc