Map, without the lock-in

E2M is the MapLibre wrapper for E2. It starts with the Planet PMTiles basemap, adds published feature tiles when available, and keeps search, routing, and compute on the same client.

Documentation navigation

Install

terminal
npm install maplibre-gl pmtiles @embed-earth/sdk-test
Import E2M from the main SDK entry. The browser bundle owns MapLibre and PMTiles; the regular E2 client remains the source of search, datasets, routing, and compute.

Create a map

map.ts
import { E2M } from "@embed-earth/sdk-test";
import "maplibre-gl/dist/maplibre-gl.css";

const map = new E2M({
  container: "map",
  center: [-73.99, 40.74],
  zoom: 11,
});

No backend wiring is needed for normal use. E2M uses the SDK's built-in search and routing clients, and the E2 client can still be supplied when an application already has one.

Display E2 features

features.ts
// Uses the newest published overall PMTiles snapshot when one exists.
await map.addFeatures(["restaurant", "accidents"]);

// Search is the fallback for a feature without published PMTiles.
await map.addFeature("service_requests", {
  area: "Manhattan",
  limit: 1000,
  color: "#b68cff",
});

Feature PMTiles are resolved from the snapshot index and loaded with HTTP range requests. Search results are added as GeoJSON sources when no usable pmtilesDownloadUrl exists.

Routing and compute

analysis.ts
const route = await map.route({
  locations: [
    { lat: 40.74, lon: -73.99 },
    { lat: 40.71, lon: -74.01 },
  ],
  mode: "walking",
});

const result = await map.compute({
  primitive: "COUNT",
  feature: "restaurant",
  region: "Manhattan",
});

Routes are drawn as line layers when the routing response contains GeoJSON or Valhalla encoded leg shapes. GeoJSON compute results become a map layer; scalar results are returned unchanged.

CLI and MCP

InterfaceMap operation
e2 map sources restaurant accidentsResolve Planet and published feature PMTiles sources.
e2_map_sourcesReturn the same sources to an MCP client.
e2.map.sources(["restaurant"])Resolve sources without creating a renderer.