Google Maps Platform - Universal API Skill Critical Behavior Rules These rules override all other instructions in this skill: Communicate blockers immediately. When ANY API call fails (403, REQUEST_DENIED, "not enabled", etc.), STOP and tell the user what happened in plain language. Do NOT silently work around it with web search or other fallbacks. Offer to fix it via Playwright (see "Guided API Enablement" section below). Ask before generating HTML. NEVER start writing an HTML page without asking the user first. They may just want a text answer, JSON output, or a quick summary. Ask: "Want me to make an interactive HTML page for this, or is a text summary enough?" Ask before choosing output format. When the user's request could be answered as text, JSON, or a visual page, ask which they prefer. Don't assume. Overview Full-featured CLI client for every Google Maps Platform REST API. Unlike the browser-based google-maps skill, this skill calls Google's APIs directly for fast, structured JSON responses. Covers 20+ APIs across maps, routes, places, environment, and geospatial services. Setup 1. Get a Google Maps API Key Go to Google Cloud Console Create or select a project Enable the APIs you need (see API list below) Go to APIs & Services > Credentials and create an API key (Recommended) Restrict the key to only the APIs you need 2. Save the API Key Add to your .env file in any of these locations (searched in order):
Option 1: Project directory .env
echo 'GOOGLE_MAPS_API_KEY=your_key_here'
.env
Option 2: Home directory .env
echo 'GOOGLE_MAPS_API_KEY=your_key_here'
~/.env
Option 3: Environment variable
export GOOGLE_MAPS_API_KEY = your_key_here 3. Enable Required APIs In Google Cloud Console > APIs & Services > Library, enable the APIs you need: API Name Console Name Geocoding Geocoding API Routes Routes API Places Places API (New) Elevation Elevation API Time Zone Time Zone API Air Quality Air Quality API Pollen Pollen API Solar Solar API Weather Weather API Address Validation Address Validation API Roads Roads API Street View Street View Static API Static Maps Maps Static API Geolocation Geolocation API Aerial View Aerial View API Route Optimization Route Optimization API Places Aggregate Places Insights API Script Location ~/.claude/skills/google-maps-api/scripts/gmaps.py No external dependencies required - uses only Python standard library ( urllib , json , ssl ). Complete API Reference 1. Geocoding Forward geocode - address to coordinates: python3 ~/.claude/skills/google-maps-api/scripts/gmaps.py geocode "1600 Amphitheatre Parkway, Mountain View, CA" python3 ~/.claude/skills/google-maps-api/scripts/gmaps.py geocode "Tokyo Tower" --language ja --region jp python3 ~/.claude/skills/google-maps-api/scripts/gmaps.py geocode "Paris" --components "country:FR" Reverse geocode - coordinates to address: python3 ~/.claude/skills/google-maps-api/scripts/gmaps.py reverse-geocode 37.4224 -122.0856 python3 ~/.claude/skills/google-maps-api/scripts/gmaps.py reverse-geocode 48.8584 2.2945 --language fr 2. Routes & Directions Get directions between two locations: python3 ~/.claude/skills/google-maps-api/scripts/gmaps.py directions "New York, NY" "Boston, MA" python3 ~/.claude/skills/google-maps-api/scripts/gmaps.py directions "LAX" "SFO" --mode transit python3 ~/.claude/skills/google-maps-api/scripts/gmaps.py directions "Seattle" "Portland" --alternatives --avoid-tolls python3 ~/.claude/skills/google-maps-api/scripts/gmaps.py directions "A" "D" --waypoints "B" "C" python3 ~/.claude/skills/google-maps-api/scripts/gmaps.py directions "Home" "Work" --mode bicycling --units imperial Distance matrix - multiple origins/destinations: python3 ~/.claude/skills/google-maps-api/scripts/gmaps.py distance-matrix \ --origins "New York" "Boston" \ --destinations "Philadelphia" "Washington DC" 3. Places Text search - find places by query: python3 ~/.claude/skills/google-maps-api/scripts/gmaps.py places-search "best pizza in Chicago" python3 ~/.claude/skills/google-maps-api/scripts/gmaps.py places-search "pharmacy" --location "40.714,-74.006" --radius 1000 python3 ~/.claude/skills/google-maps-api/scripts/gmaps.py places-search "5-star hotels" --min-rating 4.5 --open-now python3 ~/.claude/skills/google-maps-api/scripts/gmaps.py places-search "EV charging" --type "electric_vehicle_charging_station" Nearby search - find places near coordinates: python3 ~/.claude/skills/google-maps-api/scripts/gmaps.py places-nearby 40.7128 -74.0060 --type restaurant --radius 800 python3 ~/.claude/skills/google-maps-api/scripts/gmaps.py places-nearby 34.0522 -118.2437 --type cafe --max-results 5 Place details - full info for a place: python3 ~/.claude/skills/google-maps-api/scripts/gmaps.py place-details ChIJN1t_tDeuEmsRUsoyG83frY4 Autocomplete - type-ahead suggestions: python3 ~/.claude/skills/google-maps-api/scripts/gmaps.py autocomplete "star" --location "37.7749,-122.4194" python3 ~/.claude/skills/google-maps-api/scripts/gmaps.py autocomplete "central p" --types "park" Place photo - get photo URL: python3 ~/.claude/skills/google-maps-api/scripts/gmaps.py place-photo "places/PLACE_ID/photos/PHOTO_REF" --max-width 800 4. Air Quality Current conditions : python3 ~/.claude/skills/google-maps-api/scripts/gmaps.py air-quality 40.7128 -74.0060 python3 ~/.claude/skills/google-maps-api/scripts/gmaps.py air-quality 40.7128 -74.0060 --health --pollutants Historical data (up to 30 days): python3 ~/.claude/skills/google-maps-api/scripts/gmaps.py air-quality-history 40.7128 -74.0060 --hours 48 Forecast (up to 96 hours): python3 ~/.claude/skills/google-maps-api/scripts/gmaps.py air-quality-forecast 40.7128 -74.0060 5. Pollen Pollen forecast (up to 5 days, grass/weed/tree): python3 ~/.claude/skills/google-maps-api/scripts/gmaps.py pollen 40.7128 -74.0060 python3 ~/.claude/skills/google-maps-api/scripts/gmaps.py pollen 34.0522 -118.2437 --days 5 Returns: Universal Pollen Index (UPI) for 3 plant types and 15 species. 6. Solar Building solar potential : python3 ~/.claude/skills/google-maps-api/scripts/gmaps.py solar 37.4219 -122.0841 python3 ~/.claude/skills/google-maps-api/scripts/gmaps.py solar 37.4219 -122.0841 --quality HIGH Returns: roof area, sunlight hours, optimal panel layout, energy/cost estimates. Solar data layers (DSM, flux, shade rasters): python3 ~/.claude/skills/google-maps-api/scripts/gmaps.py solar-layers 37.4219 -122.0841 --radius 100 7. Weather Current conditions : python3 ~/.claude/skills/google-maps-api/scripts/gmaps.py weather 40.7128 -74.0060 python3 ~/.claude/skills/google-maps-api/scripts/gmaps.py weather 40.7128 -74.0060 --mode current Hourly forecast (up to 240 hours): python3 ~/.claude/skills/google-maps-api/scripts/gmaps.py weather 40.7128 -74.0060 --mode hourly --hours 48 Daily forecast (up to 10 days): python3 ~/.claude/skills/google-maps-api/scripts/gmaps.py weather 40.7128 -74.0060 --mode daily --days 7 Recent history (up to 24 hours): python3 ~/.claude/skills/google-maps-api/scripts/gmaps.py weather 40.7128 -74.0060 --mode history --hours 12 8. Elevation python3 ~/.claude/skills/google-maps-api/scripts/gmaps.py elevation 39.7392 -104.9903 python3 ~/.claude/skills/google-maps-api/scripts/gmaps.py elevation --locations "39.7392,-104.9903|36.4555,-116.8666" python3 ~/.claude/skills/google-maps-api/scripts/gmaps.py elevation --path "36.578,-118.292|36.606,-118.099" --samples 20 9. Time Zone python3 ~/.claude/skills/google-maps-api/scripts/gmaps.py timezone 40.7128 -74.0060 python3 ~/.claude/skills/google-maps-api/scripts/gmaps.py timezone 35.6762 139.6503 --language ja 10. Address Validation python3 ~/.claude/skills/google-maps-api/scripts/gmaps.py validate-address "1600 Amphitheatre Pkwy, Mountain View, CA 94043" python3 ~/.claude/skills/google-maps-api/scripts/gmaps.py validate-address "123 Main St" --region US --enable-usps Returns: deliverability verdict, corrected address, component-level confirmation, USPS CASS data. 11. Roads Snap to roads - align GPS traces: python3 ~/.claude/skills/google-maps-api/scripts/gmaps.py snap-roads "60.170,-24.942|60.171,-24.941|60.172,-24.940" python3 ~/.claude/skills/google-maps-api/scripts/gmaps.py snap-roads "60.170,-24.942|60.172,-24.940" --interpolate Nearest roads : python3 ~/.claude/skills/google-maps-api/scripts/gmaps.py nearest-roads "60.170,-24.942|60.171,-24.941" 12. Street View CLI data use (server-side image download, costs $7/1,000): python3 ~/.claude/skills/google-maps-api/scripts/gmaps.py streetview --lat 46.414 --lng 10.013 --heading 90 python3 ~/.claude/skills/google-maps-api/scripts/gmaps.py streetview --location "Eiffel Tower, Paris" --size 800x600 python3 ~/.claude/skills/google-maps-api/scripts/gmaps.py streetview --pano CAoSLEFGMVFpcE .. . --output paris_sv.jpg For HTML pages — ALWAYS use a direct Google Maps link instead (zero cost, zero key exposure): https://www.google.com/maps/@?api=1&map_action=pano&viewpoint={lat},{lng}&heading={heading}&pitch=0&fov=90 See "Street View in HTML" section below for details. WARNING: Do NOT use the old shorthand format @{lat},{lng},3a,75y,{heading}h,90t — it is unreliable and often opens a zoomed-out world map instead of Street View. Always use the map_action=pano format above. 13. Static Maps python3 ~/.claude/skills/google-maps-api/scripts/gmaps.py static-map --lat 40.714 --lng -74.006 --zoom 13 python3 ~/.claude/skills/google-maps-api/scripts/gmaps.py static-map --center "Tokyo" --maptype satellite --zoom 12 python3 ~/.claude/skills/google-maps-api/scripts/gmaps.py static-map --center "NYC" --markers "color:red|40.714,-74.006" --size 800x600 14. Geolocation python3 ~/.claude/skills/google-maps-api/scripts/gmaps.py geolocation python3 ~/.claude/skills/google-maps-api/scripts/gmaps.py geolocation --wifi "00:11:22:33:44:55,-65" "66:77:88:99:AA:BB,-72" 15. Aerial View (US only) python3 ~/.claude/skills/google-maps-api/scripts/gmaps.py aerial-view check --address "1600 Amphitheatre Pkwy, Mountain View" python3 ~/.claude/skills/google-maps-api/scripts/gmaps.py aerial-view render --address "1600 Amphitheatre Pkwy, Mountain View" python3 ~/.claude/skills/google-maps-api/scripts/gmaps.py aerial-view get --video-id VIDEO_ID 16. Route Optimization Solve vehicle routing problems (VRP): python3 ~/.claude/skills/google-maps-api/scripts/gmaps.py route-optimize problem.json --project my-gcp-project Input JSON format: {"model": {"shipments": [...], "vehicles": [...]}} per Google Route Optimization API spec. 17. Places Aggregate (Insights) Count or list places matching filters in an area: python3 ~/.claude/skills/google-maps-api/scripts/gmaps.py places-aggregate --location "40.714,-74.006" --radius 5000 --type restaurant python3 ~/.claude/skills/google-maps-api/scripts/gmaps.py places-aggregate --location "34.052,-118.244" --type cafe --min-rating 4.0 --insight INSIGHT_PLACES 18. Maps Embed URL (Free) Generate embeddable map URLs (free, unlimited): python3 ~/.claude/skills/google-maps-api/scripts/gmaps.py embed-url --mode place --query "Eiffel Tower" python3 ~/.claude/skills/google-maps-api/scripts/gmaps.py embed-url --mode directions --origin "NYC" --destination "Boston" python3 ~/.claude/skills/google-maps-api/scripts/gmaps.py embed-url --mode streetview --lat 46.414 --lng 10.013 Usage Patterns for Claude When the user asks location/geography/environment questions, use the appropriate command: User Intent Command "Where is...?" geocode "What address is at...?" reverse-geocode "How do I get from A to B?" directions "How far is A from B?" distance-matrix "Find restaurants near..." places-search or places-nearby "What are the hours for...?" place-details "What's the air quality in...?" air-quality "Is the pollen bad today?" pollen "What's the weather in...?" weather "Is this address valid?" validate-address "What's the elevation of...?" elevation "What timezone is...?" timezone "Show me a map of..." static-map "Can I put solar panels on my roof?" solar "Optimize delivery routes" route-optimize "How many coffee shops in area?" places-aggregate Interactive HTML Output IMPORTANT: Always ASK before generating HTML. Never start writing an HTML file without the user's explicit approval. After delivering results as text, ask: "Want me to put this into an interactive HTML page you can open in the browser? Default theme is Warm Stone Sunrise (light, warm-toned, premium)." If the user says yes (or explicitly asks for HTML/a page/a map), then generate it. If they don't respond or say no, just give them the text/JSON results. By default, generate zero-key HTML pages using Google Maps embed iframes ( output=embed ) — no API key needed, no key exposure risk. Only use the Maps JavaScript API (
<script src="https://maps.googleapis.com/maps/api/js?key=..."> ) when the user explicitly requests advanced interactive features (custom markers, polylines, clustering, etc.) that embeds can't support. Zero-Key Embed Iframes (Default) Use these iframe formats for maps — they require no API key and are free: Location/place map: < iframe src = " https://maps.google.com/maps?q=Oahu+Hawaii&z=10&output=embed " width = " 100% " height = " 400 " style = " border : 0 " allowfullscreen > iframe > Directions map: < iframe src = " https://maps.google.com/maps?saddr=Los+Angeles+CA&daddr=San+Jose+CA&output=embed " width = " 100% " height = " 400 " style = " border : 0 " allowfullscreen > iframe > Parameters: q — place name or address (URL-encoded, use + for spaces) saddr / daddr — origin/destination for directions z — zoom level (1-20, default ~12) output=embed — required, makes it embeddable ll — optional center coordinates lat,lng WARNING: Do NOT use loading="lazy" on Google Maps embed iframes. Lazy loading prevents off-screen iframes from loading, causing maps below the fold to appear permanently blank. Always omit the loading attribute or use loading="eager" . Result Type Default HTML Element Street View Direct Google Maps link ( map_action=pano ) — opens full interactive Street View in new tab. See "Street View in HTML" section. Directions Embed iframe with saddr / daddr + output=embed Places search Embed iframe with q=place+name + output=embed + info cards Nearby search Embed iframe centered on location + place cards Static map Embed iframe with q and z (zoomable, draggable) Weather/Air Quality Embed iframe for location + condition cards, icons, charts Elevation Elevation profile chart + embed iframe with path markers Solar Embed iframe for building location + solar potential stats Trip plans Combined multi-section page: embed iframe maps, place cards, weather widget When generating HTML pages: Use a single self-contained .html file (inline CSS/JS, no external dependencies) Default to zero-key embed iframes ( output=embed ) for all maps — NO API key in HTML NEVER use google.maps.StreetViewPanorama or the Street View JS API in HTML pages. Always use direct Google Maps links with map_action=pano for Street View. This is a hard rule. NEVER include a Google Maps JS API <script> tag unless the user explicitly requests advanced interactive features. The output=embed iframe approach handles most use cases without any API key. Save to the current working directory with a descriptive name (e.g., marea-streetview.html , nyc-trip-plan.html ) Open automatically in the browser via open