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 🙏

© 2026 – Pkg Stats / Ryan Hefner

leaflet-latlong-maps

v1.0.0

Published

Latlong maps with Leaflet wrapper and Latlong api suite

Readme

Leaflet Latlong Map and API Wrapper

A Leaflet wrapper with built-in Latlong authentication for raster map tiles and API suite.

  • LLMap - A wrapper to add Latlong Maps raster tile layers to Leaflet.
  • LLApi - A wrapper to access Latlong APIs. API Documentation

Installation

npm install leaflet-latlong-maps leaflet

Peer dependency: leaflet >= 1.9.0

Authentication

This library uses JWT-only authentication. Generate a JWT on your server using your client credentials, then pass it to the frontend.

{ jwt: 'your-jwt-token' }

If you do not have credentials to generate a JWT, please Sign Up to create an account.

Latlong Map Tiles

To access Latlong map tiles use LLMap or createLLMap with the sample examples below.

Option 1: Async Factory (recommended)

createLLMap returns a promise that resolves once the map is fully loaded. No callbacks needed.

import { createLLMap, L } from 'leaflet-latlong-maps';
import 'leaflet-latlong-maps/styles.css';

const llmap = await createLLMap(
  { jwt: 'your-jwt-token' },
  { container: 'map', latitude: 12.9716, longitude: 77.5946, zoom: 12 }
);

// Safe immediately
L.marker([12.9716, 77.5946]).addTo(llmap.instance);
llmap.instance.flyTo([12.9352, 77.6101], 14);
Option 2: Class with load callback
import { LLMap, L } from 'leaflet-latlong-maps';
import 'leaflet-latlong-maps/styles.css';

const llmap = new LLMap(
  { jwt: 'your-jwt-token' },
  { container: 'map', latitude: 12.9716, longitude: 77.5946, zoom: 12 }
);

llmap.on('load', () => {
  L.marker([12.9716, 77.5946]).addTo(llmap.instance);
  llmap.instance.flyTo([12.9352, 77.6101], 14);
});

How to use Leaflet functions

L.marker([12.9716, 77.5946]).addTo(llmap.instance);
L.circle([12.9716, 77.5946], { radius: 500 }).addTo(llmap.instance);
llmap.instance.flyTo([12.9352, 77.6101], 14);

Config Options

| Option | Type | Default | Description | |-----------|-----------------------|----------------|-------------------------------------| | container | string | HTMLElement | (required) | Element or ID to mount the map into | | latitude | number | 12.9716 | Map center latitude | | longitude | number | 77.5946 | Map center longitude | | zoom | number | 4 | Initial zoom level | | minZoom | number | 0 | Minimum zoom level | | maxZoom | number | 22 | Maximum zoom level | | tileUrl | string | (raster) | Custom tile layer URL | | baseUrl | string | apihub URL | Base URL for tile API |

LLMap API

| Member | Type | Description | |--------------|----------|--------------------------------------------------| | instance | property | The underlying Leaflet Map instance (after load) | | isReady | property | Whether the map has finished loading | | on('load') | method | Register a callback for when the map is ready | | destroy() | method | Remove the map and clean up | | logout() | method | Clear stored token + destroy map |

React Example

import { useEffect, useRef, useState } from 'react';
import { LLMap, L } from 'leaflet-latlong-maps';
import 'leaflet-latlong-maps/styles.css';

function MapView({ token }: { token: string }) {
  const containerRef = useRef<HTMLDivElement>(null);
  const llmapRef = useRef<LLMap | null>(null);
  const [mapReady, setMapReady] = useState(false);

  useEffect(() => {
    if (!containerRef.current || llmapRef.current) return;

    const llmap = new LLMap(
      { jwt: token },
      { container: containerRef.current, latitude: 12.9716, longitude: 77.5946, zoom: 10 }
    );

    llmap.on('load', () => {
      llmapRef.current = llmap;
      setMapReady(true);
      llmap.instance.on('click', (e) => console.log('Clicked:', e.latlng));
    });

    return () => {
      llmap.destroy();
      llmapRef.current = null;
    };
  }, [token]);

  return <div ref={containerRef} style={{ width: '100%', height: '100vh' }} />;
}

LLApi

import { LLApi } from 'leaflet-latlong-maps';

const api = new LLApi({ jwt: 'your-jwt-token' });
const location = await api.geocode('Indiranagar, Bangalore');

Available Methods

| Method | Description | |--------|-------------| | getToken() | Get current auth token (throws if expired) | | logout() | Clear stored token | | autoComplete(query, locationBias?) | Text-based location search | | autoSuggest(query, lat, lng, strictBias?) | Location-biased place search | | landmarks(lat, lng) | Nearby landmarks for a coordinate | | directions(origin, destination, headers?) | Driving route between two points | | distanceMatrix(origins, destinations) | Distance/duration matrix | | geocode(address, accuracyLevel?) | Address to coordinates | | reverseGeocode(lat, lng, details?) | Coordinates to address | | geoValidation(address, lat, lng) | Validate address against coordinates | | pincode(pincode) | Pincode information | | isochrone(distanceLimit, lat, lng) | Reachability polygon | | geofenceCreate(geojson, name?) | Create a geofence | | geofenceUpdate(geofenceId, geojson, name?) | Update a geofence | | geofenceContains(geofenceId, lat, lng, buffer?) | Point-in-geofence check | | geofenceDetails(geofenceId) | Get geofence details | | geofenceDelete(geofenceId) | Delete a geofence | | snapToRoad(coordinates) | Snap coordinates to nearest road | | addlyser(address) | Break address into structured parts | | nearestCities(address, limit?) | Find nearest cities | | votingConstituencySearch(address) | Voting constituency lookup | | trips(path, roundTrip?) | Optimized route ordering | | pointOfInterest(lat, lng, category) | POI search by category | | storePincodeSearch(pincode, limit?) | Store search within a pincode |

For detailed information about response formats, status codes, and messages, please refer to our API Documentation.

Available imports

// Core
import { LLMap, createLLMap, LLApi } from 'leaflet-latlong-maps';
import type { LLMapAuth, LLMapConfig, LLApiAuth } from 'leaflet-latlong-maps';

// Utilities
import { isTokenExpired } from 'leaflet-latlong-maps';
import { validateBBox, clampZoom, clampLatitude, clampLongitude } from 'leaflet-latlong-maps';

// Leaflet re-export (use this to avoid duplicate instances)
import { L } from 'leaflet-latlong-maps';

// Types
import type { LeafletConfig, ViewState, BBox } from 'leaflet-latlong-maps';

// Styles
import 'leaflet-latlong-maps/styles.css';

License

MIT