my-google-map-autocomplete

0.0.4 • Public • Published

MY-GOOGLE-MAP-AUTOCOMPLETE


This is a javascript that uses Google Maps Places Autocomplete, Details and Geocode to help build an app capable of leveraging the power of Google Maps Places API in an easy way. It can be used it React, React Native and other javascript related projects.

HOW TO USE


  1. Install the package.
npm i use-places-autocomplete
  1. Initialize the Google API Key in the entry point of your app.
import {Configure} from 'my-google-map-autocomplete';

Configure({
    GOOGLE_API_KEY: 'YOUR-GOOGLE-API-KEY-HERE'
});
  1. Use it normally.
import {PlaceAutocomplete, PlaceInfo, GeocodeInfo} from 'my-google-map-autocomplete';

React.useEffect(() => {
        async function locationTest() {
            const autocompleteInfo = await PlaceAutocomplete('california');
            const placenfo = await PlaceInfo(autocompleteInfo[0].place_id);
            const {lat, lng} = placenfo.geometry.location;

            const geoInfo = await GeocodeInfo(lat, lng);

            console.log(autocompleteInfo);
            console.log(placenfo);
            console.log(geoInfo);
        }

        locationTest();
}, [])

Package Sidebar

Install

npm i my-google-map-autocomplete

Weekly Downloads

0

Version

0.0.4

License

ISC

Unpacked Size

3.11 kB

Total Files

3

Last publish

Collaborators

  • neilakoh