npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

google-current-geocode

v0.0.5

Published

Quick utility package to handle location permission and use current location to get complete location info using google places geocoding api.

Downloads

49

Readme

Google Current Geocode

A quick utility package to handle location permissions and retrieve complete location information using the Google Places Geocoding API.

This package is currently in the Beta Testing phase. We are testing it with the most commonly used libraries and frameworks while aiming to create frequently used location features. Feel free to contribute!

Easy to Set Up

  1. Install this lightweight package:
  npm install google-current-geocode
  1. Get your Google API key from Google Cloud Console

  2. Add the Google API script using the best approach for your project, or simply use the setupGooglePlacesApiScript function provided by the package:

import { setupGooglePlacesApiScript } from "google-current-geocode";
  1. Invoke the setup function in the most appropriate place based on your project.
// common usage
const googleApiKey = process.env.GOOGLE_API_KEY;
if(googleApiKey) setupGooglePlacesApiScript(googleApiKey);

// for React
useEffect(() => {
    const googleApiKey = process.env.REACT_APP_GOOGLE_API_KEY;
    if(googleApiKey) setupGooglePlacesApiScript(googleApiKey)
}, [])
  1. Call the location details fetcher function anywhere in your application. This simple function requests the user’s current location permission and calls the Google Geocoding API to fetch the location details.
import { getCurrentLocationDetails } from "google-current-geocode";

// common usage
document.querySelector("#location").addEventListener("click", () => getCurrentLocationDetails());

// for React
<button onClick={() => getCurrentLocationDetails()}>Get Location</button>
  1. Ensure type safety with @types/google.maps: The package utilizes the @types/google.maps package. If it does not work as expected, you can manually install the type definitions:
npm install @types/google.maps

Options & Customizations

You can pass options to customize the behavior of the getCurrentLocationDetails function:

getCurrentLocationDetails({ cache: true })

| Name | Type | Description |
|:----------|:-------------|:-------------------------| | cache | boolean | Avoids calling the Google Geocoding API by caching location information based on latitude and longitude. |

Contributor(s)