GEMINI LABJP
FLASH35 — Gemini 3.5 Flash is now GA and powers gemini-flash-latest, making everyday generation faster and more affordableAGENTS — Managed Agents launch in public preview in the Gemini API, running in secure, isolated Google-hosted Linux sandboxesMEDIA — Nano Banana 2 Lite and Gemini Omni Flash bring faster image and high-quality video generation across AI Studio and the APITTS — Streaming speech generation is now supported for gemini-3.1-flash-tts-preview via streamGenerateContentTRANSLATE — A new audio model detects 70+ languages for live speech-to-speech translation while preserving natural intonationSPENDCAP — Project-level spend caps for billing have been added in Google AI Studio to keep costs under controlFLASH35 — Gemini 3.5 Flash is now GA and powers gemini-flash-latest, making everyday generation faster and more affordableAGENTS — Managed Agents launch in public preview in the Gemini API, running in secure, isolated Google-hosted Linux sandboxesMEDIA — Nano Banana 2 Lite and Gemini Omni Flash bring faster image and high-quality video generation across AI Studio and the APITTS — Streaming speech generation is now supported for gemini-3.1-flash-tts-preview via streamGenerateContentTRANSLATE — A new audio model detects 70+ languages for live speech-to-speech translation while preserving natural intonationSPENDCAP — Project-level spend caps for billing have been added in Google AI Studio to keep costs under control
Articles/API / SDK
API / SDK/2026-06-19Intermediate

Building location-aware AI with Gemini's Google Maps grounding: pricing and the source-display rules tutorials skip

How to ship a 'recommend something nearby' feature with Gemini API's Google Maps grounding, with the $25/1K cost design and the source-display obligations laid out for indie developers.

gemini102gemini-api274grounding8google-maps2location

Premium Article

I once wanted to add a small feature to one of my calming apps: suggest a quiet café nearby where a user could step away for a moment. Most of the apps I run as an indie developer have never touched location data, so the first thing that hit me was a practical wall — how would I ever maintain a database of places worldwide? Calling a paid Places API and building my own ranking on top is too heavy to run alone.

Gemini API's Google Maps grounding is what lets you go around that wall. It hands the model a "sense of place" and backs answers with real Google Maps data (businesses, reviews, opening hours). As of June 2026 it works on several models, including Gemini 3.5 Flash. Getting it to respond takes only a few lines — but if you ship it without understanding the billing structure and the attribution rules, it bites back later. Here are the things I sorted out while wiring it up.

Grounding hands the model a "sense of place"

Under the hood, this tool is a text search. When a user's query carries geographical context ("near me," "in San Francisco"), the model queries Google Maps and generates an answer informed by the result. If you pass latitude and longitude, "near me" style queries are interpreted around those coordinates, while specific or non-local queries are barely influenced by them.

The flow goes like this: the user sends a query with geographical intent, the model invokes the tool, the Maps service pulls places and reviews, that real data shapes the answer, and a text response comes back with sources attached. If you think of it as the "retrieve → inject context → generate" of a hand-built RAG pipeline, but specialized for place data and handled on Google's side, it clicks into place.

One thing worth noting: the tool is off by default. It only runs on requests where you explicitly enable it. That is not an oversight — given the billing and latency below, it is a welcome default.

Minimal implementation — enable the tool and pass coordinates

Start plainly. Put Google Maps into tools, and optionally pass coordinates through toolConfig. Here it is in the official Python SDK (google-genai).

from google import genai
from google.genai import types
 
client = genai.Client()  # reads GEMINI_API_KEY from the environment
 
prompt = "Is there a quiet café within a 15-minute walk from here?"
 
response = client.models.generate_content(
    model="gemini-3.5-flash",
    contents=prompt,
    config=types.GenerateContentConfig(
        # Turn on Google Maps grounding
        tools=[types.Tool(google_maps=types.GoogleMaps())],
        # Optional: pass the user's location as context (this is near Tokyo Station)
        tool_config=types.ToolConfig(
            retrieval_config=types.RetrievalConfig(
                lat_lng=types.LatLng(latitude=35.681236, longitude=139.767125)
            )
        ),
    ),
)
 
print(response.text)

JavaScript (@google/genai) has the same shape: put googleMaps: {} in tools, and pass coordinates to toolConfig.retrievalConfig.latLng.

import { GoogleGenAI } from "@google/genai";
 
const ai = new GoogleGenAI({}); // GEMINI_API_KEY from the environment
 
const response = await ai.models.generateContent({
  model: "gemini-3.5-flash",
  contents: "Is there a quiet café within a 15-minute walk from here?",
  config: {
    tools: [{ googleMaps: {} }],
    toolConfig: {
      retrievalConfig: {
        latLng: { latitude: 35.681236, longitude: 139.767125 },
      },
    },
  },
});
 
console.log(response.text);

Ask for "cafés nearby" and you will get a plausible answer. But putting that on screen as-is violates the terms, because you must display the returned sources according to the rules.

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
Get a minimal 'recommend something nearby' implementation running on Gemini 3.5 Flash, in both Python and JavaScript, without owning a place database
Understand why $25 / 1K separate-line billing makes 'always on' unsustainable, and switch to a design that enables the tool only when the query is geographical
Meet the groundingChunks source-display obligations (Google Maps attribution rules) and avoid the policy issues that can get your app cut off
Secure payment via Stripe · Cancel anytime

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Gemini Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • Copy-paste ready implementation code
  • New advanced guides published daily
  • $5/mo or $10 for lifetime access
View Membership →

Related Articles

API / SDK2026-06-24
Citing the exact page and figure in File Search answers with visual-citation metadata
File Search grounding metadata now carries media_id and page_numbers, so you can trace each sentence of an answer back to a specific page and figure. Here's how I built a sentence-level, verifiable citation layer over a mix of PDFs and images.
API / SDK2026-07-14
When Gemini's executed result and its prose disagree on a number — a gate that trusts only code_execution_result
Gemini Code Execution returns the value it actually computed and the sentence describing it as separate parts. Trust the prose and you can inherit a hallucinated number. Here is a verification gate, in working code, that extracts the executed result as the single source of truth and rejects prose that disagrees.
API / SDK2026-07-13
When responseSchema Can't Do $ref: Handling Recursive Schemas in Production with responseJsonSchema
Gemini's responseSchema is an OpenAPI subset with no $ref or $defs, so it can't express shared definitions or recursion. Here's how I moved to responseJsonSchema to reuse localized fields and handle a recursive category tree in production.
📚RECOMMENDED BOOKS
Build a Large Language Model (From Scratch)
Sebastian Raschka
LLM Dev
Prompt Engineering for LLMs
Berryman & Ziegler
Prompting
AI Engineering
Chip Huyen
AI Eng
* Contains affiliate links
See all →