◉GEMINI LABJP
●ARGON — gemini-4-argon is generally available as of 10/13, aimed at complex coding, agents, math and science●DEEP RES — deep-research-pro-preview-12-2025 shuts down 10/23, 6 days left. Move to deep-research-preview-04-2026●NANO — gemini-nano-banana-2.1 is GA (10/06). gemini-3.1-flash-image is deprecated with no shutdown date yet●MCP — One write-up cut an 85,000-token tool result to 310 tokens by wrapping it in an ADK FunctionTool●FLASH — gemini-3.7-flash and 3.5-flash now route automatically to newer Flash models (10/08)●NEW — Stop Re-Reading Every Crash Report: Gre…●ARGON — gemini-4-argon is generally available as of 10/13, aimed at complex coding, agents, math and science●DEEP RES — deep-research-pro-preview-12-2025 shuts down 10/23, 6 days left. Move to deep-research-preview-04-2026●NANO — gemini-nano-banana-2.1 is GA (10/06). gemini-3.1-flash-image is deprecated with no shutdown date yet●MCP — One write-up cut an 85,000-token tool result to 310 tokens by wrapping it in an ADK FunctionTool●FLASH — gemini-3.7-flash and 3.5-flash now route automatically to newer Flash models (10/08)●NEW — Stop Re-Reading Every Crash Report: Gre…
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.

gemini119gemini-api286grounding8google-mapslocation

✦ 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-09-04
Screen Loop Seam Clicks With Numbers Before You Hand the Audio to Gemini
An ambient loop that clicks only at the wrap point. Here is the numeric prescreen I run before sending anything to audio understanding, why an absolute threshold fails, and how AAC encoding quietly rebuilt the seam I had just repaired.
◈ API / SDK2026-08-23
Moving app AI work from runtime calls to a pre-ship batch pass
Where you put a Gemini call decides whether your request count scales with users or with assets. Here is the decision rule I used to move classification into a pre-ship batch pass, plus a resumable implementation.
◈ API / SDK2026-08-22
Once You Pass Twenty Mediation Groups, How Do You Find the Setting That Went Missing?
As ad mediation groups multiply, missing sources and type drift accumulate quietly. Here is the split I settled on: normalize the settings into one matrix, let code confirm the gaps, and send Gemini only the cells that need judgment.