Map ProvidersGoogle Maps

Google Maps

Global satellite imagery via the Google Map Tiles API (session + XYZ)

Use Google’s Map Tiles API 2D satellite tiles for GeoAI inference. Requires a Google Maps Platform API key with Map Tiles API enabled (billing required).

Setup

import { geoai } from "geoai";
 
const pipeline = await geoai.pipeline([{ task: "building-detection" }], {
  provider: "google",
  apiKey: process.env.GOOGLE_MAPS_API_KEY!,
  // optional: mapType: "satellite",
  // optional: sessionToken: "...", // reuse a pre-created session
});
 
const results = await pipeline.inference({
  inputs: { polygon: myPolygon },
  mapSourceParams: { zoomLevel: 18 },
});
🔑

The provider creates a Map Tiles session (POST /v1/createSession) on first image fetch, caches it, and refreshes near expiry. Tile requests use GET /v1/2dtiles/{z}/{x}/{y}?session=…&key=….

Parameters

type GoogleMapsParams = {
  provider: "google";
  apiKey: string;
  mapType?: "satellite" | "roadmap" | "terrain"; // default satellite
  language?: string; // default en-US
  region?: string; // default US
  sessionToken?: string; // optional pre-created session
  attribution?: string;
  tileSize?: number;
  headers?: Record<string, string>;
};

Notes

  • Not free — Map Tiles API is billed per request; enable the API in your GCP project.
  • API key restrictions — Map Tiles is a web service. Do not use an HTTP-referrer–restricted key (Maps JavaScript keys). Use no application restriction or IP restriction. Referrer-restricted keys often fail with 401 API keys are not supported / CREDENTIALS_MISSING.
  • Browser apps — prefer a same-origin proxy that keeps the key server-side (see live-examples /api/google-tiles).
  • Terms of Service — follow Map Tiles API policies (attribution, caching limits). Do not scrape unofficial mt*.google.com tile hosts.
  • Map UI — MapLibre cannot legally use Google tiles as a basemap in most cases. Prefer ESRI/Mapbox/OAM for map display and Google for inference, or use the Google Maps JavaScript SDK for the map layer.

References