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

g-mapify

v2.3.1

Published

Flexible react google map with more options of search, pick & select.

Downloads

1,003

Readme

g-mapify NPM version Downloads All Contributors

Flexible react google map with more options of search, pick & select.

g-mapify

g-mapify

Getting Started

yarn add g-mapify

or

npm i g-mapify

Usage

Basic use:

    import  React from  'react';
    import { GMapify } from  'g-mapify';
    import  'g-mapify/dist/index.css';
    
    const  App = () => {
	    return (
		    <GMapify appKey="[google-map-key]" />
	    )
    }

Example: Basic map

basic map image

Example with options (Search Map)

import  React from  'react';
import { GMapify } from  'g-mapify';
import  'g-mapify/dist/index.css';

const  App = () => {
    const  onMapSelect = (status, data) => console.warn(status, data);
    
    return (
        <GMapify appKey="[google-map-key]" hasSearch onSelect={onMapSelect}/>
    )
}

Note

If status is getting false that means something happened bad on location search.

Map Search image

Example with multiple markers

import  React from  'react';
import { GMapify } from  'g-mapify';
import  'g-mapify/dist/index.css';

const  App = () => {

    const markers = [
        [28.4165425, 77.0437857, "Hello 1"],
        [28.415671, 77.0520993, `<div><h3>Southcity 2</h3> <img src="https://www.rentomojo.com/blog/wp-content/uploads/2019/07/shutterstock_1298400742.jpg" height="140"/> </div>`],
        [28.4175717, 77.05284840000002]
    ]

    const  onMapSelect = (status, data) => console.warn(status, data);
    
    return (
        <GMapify 
        appKey="[google-map-key]" 
        customMarkers={markers}
        autoCenter={false}
        onSelect={onMapSelect}/>
    )
}

Map Mutiple markers image

Options

| Props | Description | Default value |-------------------------------|-------------------------------------------------------|-------------------------------| |appKey (Mandatory) | google map app key | It's a mandatory value |lat | default latitude of map | 28.7041 |lng | default logitude of map | 77.1025 |mapOptions | google map options that you can change or add more | zoom: 15, zoomControl: false, mapTypeControl: false, fullscreenControl: false, streetViewControl: false, clickableIcons: false, mapTypeId: "roadmap" |libraries | add more funcationality on google map | places |mapClassName | custom class name for map element | None |hasMarker | show marker in map | true |markerIcon | map marker icon | Blue marker icon |autoCenter | Auto center map on move or zoom | true |customMarkers | Multiple custom markers to mark on map | [] (Example : [[lat, lng, content], [lat, lng, content], ...] ) |allowSinglePopup | Allow to open single popup on click custom marker | true |hasSearch | apply search in map | false |mapSearchPlace | map search input box place (required a valid selector name like (#id, .class)) | bottom of the map |debounceTime | search debounce time (unit ms) | 2000 |inputClassName | custom class name for Search input | None |searchPlaceHolder | placeholder of search box | Search here |searchClassName | custom class name of search container | None |onSelect | trigger whenever map position changed (return status: [true/false], data: [map data object], mapStatus: [map native status])|

Note

When use customMarkers (More than 1) - Make sure autoCenter, hasSearch are set to false. Which dosen't make sense any way with multiple markers.

Using Ref (v2.3.0)

Support ref to access some functions directly.

    import  React from  'react';
    import { GMapify } from  'g-mapify';
    import  'g-mapify/dist/index.css';
    
    const  App = () => {
        const mapRef = useRef();

        const getLatLongByName = async () => {
            if (mapRef.current) {
                try {
                    const result = await mapRef.current.latLongFromQuery('BharatPe Office Delhi');
                    const lat = result[0]?.geometry.location.lat();
                    const lng = result[0]?.geometry.location.lng();
                } catch (e) {
                    // handle error
                }
            }
        };

	    return (
            <>
                <button onClick={getLatLongByName}>BharatPe Office Location</button>
                <GMapify ref={mapRef} appKey="[google-map-key]" />
            </>
	    )
    }

Functions are accessible directly:

| Function | Description | Parameters | Return Value |-------------------------------|----------------------------------------------------------|-------------------------------|------------------------- |latLongFromQuery | Get Map data from address string without showing search | string | Promise<map data>

Address Formatter

You can get City, Pincode, State etc. from address_components using addressFormatter method. This method transfrom address_components array data into object.

import { GMapify, AddressFormatter } from  'g-mapify'

const  onMapSelect = (status, data) => {
    if (status) {
        console.warn('Map Data', data);
        
        // get formatted address from google map address_components
        const  formattedAddress = AddressFormatter(data.address_components);
        console.warn('formated address', formattedAddress);
    }
};

Refer example for all 3 map variations

Map variations image

Releases

Here Releases

Note: For Contributors

This repo build with create-react-library

Contributors

Here Contributors

License

ISC BharatPe TM