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

@googlemap-react/core

v0.1.14

Published

Easier-to-use Google Map & React integration

Downloads

1,362

Readme

googlemap-react

All Contributors

npm package License: MIT codecov codebeat badge

Join the community on Spectrum

Easier Google Map Integration for React projects.

READ THE DOC

Why a new package

There has been similar packages such as tomchentw/react-google-maps, google-map-react/google-map-react, fullstackreact/google-maps-react, so why bother writing a new library?

The aim is to make an easier-to-use Google Map library for React users, empowered by React's latest features (React >= 16.8.0 is required) and TypeScript.

What is different

  • Component position is free (generally)
  • Direct access to Google Map objects
  • More uniform API
  • Type safe

Example usage

Prerequisites

  • npm or yarn
yarn add @googlemap-react/core
# Or you can use
npm install --save @googlemap-react/core
  • a valid Google Map API key (to replace the place holder in the code snippet below)
import {
  GoogleMapProvider,
  HeatMap,
  InfoWindow,
  MapBox,
  Marker,
  OverlayView,
  Polygon,
} from '@googlemap-react/core'

// In your component
return (
  <GoogleMapProvider>
    <MapBox
      apiKey="YOUR_GOOGLE_MAP_API_KEY"
      opts={{
        center: {lat: 39, lng: 116},
        zoom: 14,
      }}
      style={{
        height: '100vh',
        width: '100%',
      }}
      useDrawing
      useGeometry
      usePlaces
      useVisualization
      onCenterChanged={() => {
        console.log('The center of the map has changed.')
      }}
    />
    <Marker
      id="marker"
      opts={{
        draggable: true,
        label: 'hello',
        position: {lat: 39, lng: 116},
      }}
    />
    <InfoWindow
      opts={{
        content: 'This is an info window',
        position: {lat: 39.01, lng: 115.99},
      }}
      visible
    />
    <Polygon
      id="polygon"
      opts={{
        path: [
          {lat: 38.98, lng: 116.01},
          {lat: 38.98, lng: 116.03},
          {lat: 38.99, lng: 116.03},
        ],
        strokeColor: 'cyan',
      }}
    />
    <HeatMap
      opts={{
        data: [
          {lat: 38.982, lng: 116.037},
          {lat: 38.982, lng: 116.035},
          {lat: 38.985, lng: 116.047},
          {lat: 38.985, lng: 116.045},
        ],
      }}
    />
    <OverlayView position={{lat: 39, lng: 116}}>
      <h2>⚑ This is a custom overlay 🙌</h2>
    </OverlayView>
  </GoogleMapProvider>
)

For more detailed explanation, see the doc.

Advanced usage

Instead of using the pre-designed components, you can also use the exported hooks useGoogleAPI, useGoogleListeners in your own components.

See the examples

First, you need to clone the repository and install the dependencies:

git clone https://github.com/googlemap-react/googlemap-react
cd googlemap-react
yarn install

Styleguide

To read the styleguide locally, simply run:

yarn styleguide

And you can then go to http://localhost:6060 to see the styleguide.

CRA (Create-React-App) example

You can also run the example app. Before running it locally, you should copy the sample dotenv file, and fill in your Google Map API key to replace the placeholder.

cd examples/CRA
cp .env.sample .env

Then you can run the example project by

yarn start

Projects using this package

Boycott github|site

This app combines Google Map API and Yelp API, helping users search nearby businesses.

Screenshot

Stargazers over time

Stargazers over time

Contributors ✨

Thanks goes to these wonderful people (emoji key):

This project follows the all-contributors specification. Contributions of any kind welcome!