Google Maps V3 Utility Libraries (Community Fork)

1.0.1 · abandoned · verified Sun Apr 19

This package is a community-maintained fork of the Google Maps JavaScript API v3 utility libraries, initially updated around 2018. It bundles a collection of client-side JavaScript components such as MarkerClusterer, InfoBox, InfoBubble, KeyDragZoom, and RouteBoxer. These utilities are designed to extend the core functionality of Google Maps v3 by providing enhanced marker management, custom information windows, and map interaction tools. Despite its `latest` moniker, the package's content reflects updates from 2018, making its compatibility with recent Google Maps API versions potentially limited. The current version is 1.0.1, and it does not appear to follow an active release cadence, suggesting it is in a frozen or abandoned state, differing from the potentially more current official Google Maps utility library repositories.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates initializing a Google Map and adding a MarkerClusterer with random markers, using the package's primary export. Includes conditional loading for the Google Maps API.

import MarkerClusterer from 'googlemaps-v3-utility-library-latest';

function initMap() {
  const map = new google.maps.Map(document.getElementById('map'), {
    zoom: 3,
    center: { lat: -28.024, lng: 140.887 },
    mapId: 'DEMO_MAP_ID' // Replace with your Map ID
  });

  const markers = [];
  // Create some random markers
  for (let i = 0; i < 100; i++) {
    const latLng = new google.maps.LatLng(
      -28.024 + Math.random() * 10,
      140.887 + Math.random() * 10
    );
    markers.push(new google.maps.Marker({
      position: latLng
    }));
  }

  // Add a marker clusterer to the map.
  new MarkerClusterer(map, markers, {
    imagePath: 'https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/m'
  });
}

// Ensure the global `google` object is available (e.g., via script tag in HTML)
// For demonstration purposes, if not using a global callback, call directly:
// This assumes the Google Maps API script is loaded globally and defines `google`
// For a real application, follow Google's recommended async loading with a callback.
window.addEventListener('DOMContentLoaded', () => {
  if (typeof google !== 'undefined' && google.maps) {
    initMap();
  } else {
    console.warn('Google Maps API not loaded. Ensure the script tag is present.');
    // You might want to dynamically load it here or handle the missing global differently
    const script = document.createElement('script');
    script.src = `https://maps.googleapis.com/maps/api/js?key=${process.env.GOOGLE_MAPS_API_KEY ?? 'YOUR_API_KEY'}&callback=initMap`;
    script.async = true;
    document.head.appendChild(script);
    window.initMap = initMap; // Attach to window for the callback
  }
});

view raw JSON →