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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@gmaps-kit/core

v1.1.0

Published

Framework-agnostic core utilities for Google Maps JavaScript SDK - geocoding, directions, places, markers, street view, and more

Readme

@gmaps-kit/core

Framework-agnostic core utilities for Google Maps JavaScript SDK - geocoding, directions, places, markers, street view, and more.

npm version License: MIT

🚀 Live Demo

Try it out: https://demo-app-rouge-five.vercel.app/

See all features in action with interactive examples!

Features

  • 🗺️ Map Management - Create and manage Google Maps instances
  • 📍 Geocoding - Convert addresses to coordinates and vice versa
  • 🧭 Directions - Get driving, walking, and transit directions
  • 🏢 Places - Search and get details about places
  • 📌 Markers - Add, remove, and manage map markers
  • 🛣️ Street View - Integrate Street View panoramas
  • 🔍 Autocomplete - Add place autocomplete functionality
  • 📦 Framework Agnostic - Works with any JavaScript framework
  • 🎯 TypeScript - Full TypeScript support with type definitions
  • Lightweight - Optimized bundle size (~21KB)

Installation

npm install @gmaps-kit/core

Quick Start

1. Load Google Maps API

import { loadGoogleMaps } from '@gmaps-kit/core';

// Load Google Maps API
await loadGoogleMaps({
  apiKey: 'YOUR_API_KEY',
  libraries: ['places', 'geometry'],
});

2. Create a Map

import { createMap } from '@gmaps-kit/core';

const mapInstance = createMap('map-container', {
  center: { lat: 40.7128, lng: -74.006 },
  zoom: 10,
});

3. Add Markers

import { addMarker, createInfoWindow } from '@gmaps-kit/core';

// Add a marker
const marker = addMarker(mapInstance.map, {
  position: { lat: 40.7128, lng: -74.006 },
  title: 'New York City',
});

// Create an info window
const infoWindow = createInfoWindow({
  content: '<h3>New York City</h3><p>The Big Apple!</p>',
});

Core Features

Geocoding

import { geocode, reverseGeocode } from '@gmaps-kit/core';

// Convert address to coordinates
geocode('New York City', (results, status) => {
  if (status === 'OK') {
    console.log(results[0].geometry.location);
  }
});

// Convert coordinates to address
reverseGeocode({ lat: 40.7128, lng: -74.006 }, (results, status) => {
  if (status === 'OK') {
    console.log(results[0].formatted_address);
  }
});

Directions

import { getDirections, renderDirections } from '@gmaps-kit/core';

getDirections(
  {
    origin: 'New York, NY',
    destination: 'Boston, MA',
    travelMode: 'DRIVING',
  },
  (result, status) => {
    if (status === 'OK') {
      renderDirections(mapInstance.map, result);
    }
  }
);

Places (Legacy API)

import { PlacesClient } from '@gmaps-kit/core';

const placesClient = new PlacesClient({
  apiKey: 'YOUR_API_KEY',
});

// Search for places
const results = await placesClient.textSearch({
  query: 'restaurants in New York',
  location: { lat: 40.7128, lng: -74.006 },
  radius: 1000,
});

Places API (New) - Enhanced Features

import { PlacesNewClient } from '@gmaps-kit/core';

const placesNewClient = new PlacesNewClient({
  apiKey: 'YOUR_API_KEY',
});

// Text search with enhanced data
const textResults = await placesNewClient.textSearch({
  textQuery: 'restaurants in New York',
  locationBias: {
    circle: {
      center: { latitude: 40.7128, longitude: -74.006 },
      radius: 1000,
    },
  },
  maxResultCount: 10,
  minRating: 4.0,
});

// Nearby search with better CORS support
const nearbyResults = await placesNewClient.nearbySearch({
  includedTypes: ['restaurant', 'cafe'],
  locationRestriction: {
    circle: {
      center: { latitude: 40.7128, longitude: -74.006 },
      radius: 1000,
    },
  },
  maxResultCount: 10,
  minRating: 4.0,
});

// Get detailed place information
const placeDetails = await placesNewClient.placeDetails({
  placeId: 'ChIJN1t_tDeuEmsRUsoyG83frY4',
});

// Place autocomplete
const autocompleteResults = await placesNewClient.autocomplete({
  input: 'restaurants in',
  locationBias: {
    circle: {
      center: { latitude: 40.7128, longitude: -74.006 },
      radius: 1000,
    },
  },
});

// Get place photos
const photo = await placesNewClient.getPhoto({
  name: 'photos/123',
  maxWidthPx: 400,
  maxHeightPx: 300,
});

// Build photo URL
const photoUrl = placesNewClient.buildPhotoUrl('photos/123', {
  maxWidthPx: 400,
  maxHeightPx: 300,
});

Autocomplete

import { createAutocomplete, bindAutocompleteToMap } from '@gmaps-kit/core';

const autocomplete = createAutocomplete(
  document.getElementById('search-input'),
  {
    types: ['establishment'],
    componentRestrictions: { country: 'us' },
  }
);

bindAutocompleteToMap(autocomplete, mapInstance.map);

API Reference

Map Functions

  • createMap(container, options, eventHandlers?) - Create a new map instance
  • getMapCenter(map) - Get map center coordinates
  • setMapCenter(map, center) - Set map center
  • getMapZoom(map) - Get current zoom level
  • setMapZoom(map, zoom) - Set zoom level
  • panTo(map, location) - Pan to a location
  • fitMapToMarkers(map, markers) - Fit map to show all markers

Marker Functions

  • addMarker(map, options) - Add a marker to the map
  • removeMarker(marker) - Remove a marker
  • updateMarkerPosition(marker, position) - Update marker position
  • updateMarkerContent(marker, content) - Update marker content
  • setMarkerDraggable(marker, draggable) - Set marker draggable state

Geocoding Functions

  • geocode(address, callback) - Geocode an address
  • reverseGeocode(location, callback) - Reverse geocode coordinates
  • geocodeAsync(address) - Async geocoding
  • reverseGeocodeAsync(location) - Async reverse geocoding

Directions Functions

  • getDirections(request, callback) - Get directions
  • getDirectionsAsync(request) - Async directions
  • renderDirections(map, result) - Render directions on map
  • clearDirections(map) - Clear directions from map

TypeScript Support

This package includes full TypeScript definitions:

import type {
  MapOptions,
  MarkerOptions,
  GeocodingResult,
} from '@gmaps-kit/core';

const mapOptions: MapOptions = {
  center: { lat: 40.7128, lng: -74.006 },
  zoom: 10,
};

Browser Support

  • Chrome 60+
  • Firefox 55+
  • Safari 12+
  • Edge 79+

License

MIT © gmaps-kit

Contributing

Contributions are welcome! Please read our Contributing Guide for details.

Support