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

map-google-react

v2.0.2

Published

A highly customizable `Google Map` component which exposes complete customization options. It uses Google's `Places API` for Autocomplete options and fetching the details of a location. It also uses the `Geococoder API` to get the details of a coordinate.

Downloads

18

Readme

map-google-react

A highly customizable Google Map component which exposes complete customization options. It uses Google's Places API for Autocomplete options and fetching the details of a location. It also uses the Geococoder API to get the details of a coordinate. SearchBox component is exported which can be used as a child of GoogleMap component to make it customizable and controllable separately.

Installation

Use the package manager yarn to install map-google-react.

yarn add map-google-react

or using npm

npm install map-google-react

Usage

import { GoogleMap, SearchBox } from 'map-google-react';
<GoogleMap
    googleMapUrl={`https://maps.googleapis.com/maps/api/js?key=<MAP_API_KEY>&libraries=places,geocoder`}
>
    <SearchBox />
</GoogleMap>

Props

GoogleMap

| Prop | Type | Default | Description | | :----------: | :-------------: | :-----: | :-----------------------------------: | | googleMapUrl | string | - | Google map url with API key. (libraries needed: places & geocoder) Ex: https://maps.googleapis.com/maps/api/js?key=<MAP_API_KEY>&libraries=places,geocoder | | markerIconUrl | string | https://maps.gstatic.com/mapfiles/api-3/images/spotlight-poi2_hdpi.png | Url for the marker icon. Image located on the url should be of expected size of the marker. | | defaultCenter | { lat: number; lng: number } | { lat: 26.850000, lng: 80.949997 } | Default center for the map when it is loaded | | defaultMarker | { lat: number; lng: number } | - | Default marker to be diplayed on map when it is loaded. This overrides defaultCenter prop. | | defaultZoom | number (0 - 18) | 14 | Default zoom factor for the google map | | mapOptions | google.maps.MapOptions | { mapTypeId: google.maps.MapTypeId.ROADMAP, mapTypeControl: false, streetViewControl: false, fullscreenControl: false, scaleControl: false, zoomControl: true, disableDoubleClickZoom: true, clickableIcons: false } | Fields array accepted by Google maps Places API. This is going to save your cost. :D | | placesOptions | Array | ['geometry', 'formatted_address'] | Fields array accepted by Google maps Places API. This is going to save your cost. :D | | markerOptions | google.maps.ReadonlyMarkerOptions | - | Marker options to customize marker. (Note: markerIconUrl has precedence over the icon prop here) | | infoWindowLoader | JSX.Element | - | Loader to show inside info window till the details are loaded | | infoWindow | string | <div style="display: flex; flex-direction: column; justify-content: center; font-size: 0.918rem; min-height: 28px;"><b>mainText</b>secondaryText</div> | Stringified element for Info Window with mainText and secondaryText in place. These keywords are replaced with actual values. | | beforeChange | () => void | - | Gets called before the change starts. In case you need to disable any confirm button in place till new location is selected. | | onPlacesChange | (coordinates: { [key: string]: number }, callback: (place: string) => void) => void; | - | Receives the coordinates { lat, lng } and then expects user to do callback with the location text separated by hyphen (-). eg: 'Para - Lucknow'. This is helpful when we fetch the location from coordinates on our own server to create a database, and then pass that to callback so next time for a same request we don't need to fetch details from google. This will bypass the Geocoder API and more savings. :D | | afterChange | (data: { lat: number, lng: number, place: string }) => void | - | Gets called once map is finished updating and returns the final lat, lng and the location text | | onError | (error: any) => void | - | Gets called an error is ocurred |

SearchBox

| Prop | Type | Default | Description | | :----------: | :-------------: | :-----: | :-----------------------------------: | | placeholder | string | 'Search location' | Placeholder for the search input | | inputStyles | CSSProperties | - | Custom styles for the input element | | suggestionStyles | CSSProperties | - | Custom styles for a single suggestion in autocomplete | | searchOptions | google.maps.places.AutocompletionRequest | - | Custom options for the AutoComplete API |

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT