React Hook-based Google Maps API Integration

A lightweight React hook-based Flow-typed library for a simple Google Maps API usage.

Install & Import:

# NPM
$ npm i ya-google-maps-react --save

import useGoogleAPI from './index';

Basic Usage:

const MyComponent = (): React.Node => {
  const googleApi = useGoogleAPI('MY-API-KEY-HERE');
  const mapRef = React.useRef(null);  
  React.useEffect(() => {
    if (googleApi === null) return;
    new googleApi.maps.Map(mapRef.current, {
    center: { lat: -34.397, lng: 150.644 },
    zoom: 8,
    });
  }, [googleApi]);
}

Preview:

React Hook-based Google Maps API Integration-min

Download Details:

Author: bertuz

Live Demo: View The Demo

Download Link: Download The Source Code

Official Website: https://github.com/bertuz/ya-google-maps-react

License: MIT

You Might Be Interested In:

Add Comment