Enterprise GIS Workbench, GeoJSON Zones & Deck.gl Analytics — Python FastAPI Backend + Interactive Web Frontend (Map, AdvancedMarkerElement, PinElement, PlaceAutocompleteElement, Places API (New), Elevation API)
An enterprise Web GIS spatial analytics workbench centered on New York City (40.73061, -73.98661), pairing an async Python FastAPI Backend-for-Frontend (BFF) proxy with a full-viewport split-screen web client powered by the Google Maps JavaScript API, GeoJSON Data Layer, deck.gl GoogleMapsOverlay, Terra Draw, Places API (New), and the Elevation API.
- FastAPI BFF (
main.py):- Serves the interactive frontend from
static/(index.html,styles.css,app.js,nyc-data.js). - Exposes
/api/configsoGOOGLE_MAPS_API_KEYis loaded from.envat runtime and never hardcoded in client source files. - Proxies
POST /api/places/searchtohttps://places.googleapis.com/v1/places:searchTextwithX-Goog-Api-Keyand an explicitX-Goog-FieldMask(places.id,places.displayName,places.formattedAddress,places.location,places.types), avoiding browser CORS restrictions. - Proxies
POST /api/elevationtohttps://maps.googleapis.com/maps/api/elevation/json, validating coordinates with Pydantic and projecting onlyelevation,location,resolution, andstatus. - Adds
X-Content-Type-Options: nosniffandX-Frame-Options: SAMEORIGINsecurity headers and binds strictly to127.0.0.1.
- Serves the interactive frontend from
- Interactive GIS Frontend (
static/app.js):- Uses the Google Maps JS Dynamic Library Import bootstrap (
google.maps.importLibrary) forcore,maps,marker,places, andelevationwithmapId: "DEMO_MAP_ID"andinternalUsageAttributionIds: ["gmp_git_agentsamples_v1.0.0"]. - Live basemap switcher (
roadmap,satellite,hybrid,terrain) and GeoJSON district boundary layer (map.data.addGeoJson) styled by grid capacity utilization with smoothmap.fitBounds()zoom-on-select. - WebGL2-checked
deck.glGoogleMapsOverlay(ScatterplotLayerandHexagonLayer) visualizing 2,400 infrastructure sensor points with graceful 2D fallback in headless environments. - Interactive Terra Draw (
terra-draw+terra-draw-google-maps-adapter) polygon drawing & editing toolbar for custom study-zone point-in-polygon filtering, area calculation, and Elevation API terrain profiling. - Live
PlaceAutocompleteElement(gmp-selectevent) and civic reference hubs rendered withAdvancedMarkerElementandPinElement.
- Uses the Google Maps JS Dynamic Library Import bootstrap (
@app.post("/api/places/search")
async def search_places(payload: PlaceSearchRequest) -> JSONResponse:
headers = {
"Content-Type": "application/json",
"X-Goog-Api-Key": api_key,
"X-Goog-FieldMask": "places.id,places.displayName,places.formattedAddress,places.location,places.types",
}
async with httpx.AsyncClient(timeout=12.0) as client:
upstream = await client.post(
"https://places.googleapis.com/v1/places:searchText",
json={"textQuery": payload.textQuery, "maxResultCount": payload.maxResultCount},
headers=headers,
)Option A — Free Maps Demo Key (Prototyping, No Billing Required):
- Open the Google Maps Demo Key Console.
- Sign in with any Google account and accept the Maps Demo Project Terms.
- Generate and copy your Demo Key (note: daily quota limits apply; not for production).
Option B — Production Google Cloud Key:
- Create an API key in Google Cloud Console Credentials.
- Enable Maps JavaScript API, Places API (New), and Elevation API.
- Follow API Key Security Best Practices to restrict your key by HTTP referrer / server IP and designated APIs.
cp .env.example .env
# Edit .env and set GOOGLE_MAPS_API_KEY=<your_key>python3 -c "import pathlib, venv; p=pathlib.Path('.venv'); venv.create(p, with_pip=True) if not (p/'bin'/'pip').exists() else None"
.venv/bin/pip install -r requirements.txt
.venv/bin/python -m compileall -q -x '^\./?\.venv' .
.venv/bin/uvicorn main:app --host 127.0.0.1 --port 8000Open http://127.0.0.1:8000 in your browser.
- Maps JavaScript API Documentation
- Places API (New) Text Search
- Elevation API Overview
- Terra Draw on Google Maps
- Google Maps Platform Terms of Service
static-vanilla-jsreact-vitenextjssveltekitvue-viteangularpython-fastapi(current implementation)nodejs-web
- Cost Notice: "Usage of Google Maps Platform products and services may incur costs against your Google Cloud project billing account." Requires a billed Google Cloud key for Elevation API (REST) (a Maps Demo Key covers Maps JS/Places/Routes/Geocoding/Weather prototyping only).
- API Key Restrictions: Restrict production keys by HTTP referrer (client) or IP address (server) and allowed APIs via Add API Key Restrictions.
- License Scope: Google-sourced code snippets are provided "as-is" under the Apache 2.0 License (applies to Google-sourced snippets only, not the full generated project).
- Terms of Service: Subject to the Google Maps Platform Terms of Service, EEA Service Specific Terms, and Prohibited Territories. Do not cache non-
place_idPlaces data or use GMP content for AI/ML training. - Browse Catalog:
../README.md·../AGENTS.md·../../AGENTS.md·../../INDEX.md