Google Maps

GoogleMapTools search places, get directions, geocode addresses, and check elevation, timezone, and distance data through the Google Maps API.

GoogleMapTools enable an Agent to interact with various Google Maps services for location-based operations including place search, directions, geocoding, and more.

Prerequisites

The following example requires the googlemaps and google-maps-places libraries and an API key which can be obtained from the Google Cloud Console.

uv pip install agno googlemaps google-maps-places openai
export GOOGLE_MAPS_API_KEY=your_api_key_here

The toolkit constructs both a key-based googlemaps.Client and an ADC-based PlacesClient. Configure Application Default Credentials even if you disable place search:

gcloud auth application-default login

Enable Places API (New) and billing for the credentials' project. The key-based methods also require their corresponding APIs. Legacy Directions and Distance Matrix APIs remain supported for eligible existing projects but are unavailable to new projects; see Google Maps legacy services.

Example

This example uses Places API (New) only:

from agno.agent import Agent
from agno.tools.google.maps import GoogleMapTools

agent = Agent(tools=[GoogleMapTools(include_tools=["search_places"])])
agent.print_response("Find coffee shops in San Francisco")

For more examples, see the Google Maps Tools example.

Toolkit Params

ParameterTypeDefaultDescription
keyOptional[str]NoneOptional API key. If not provided, uses GOOGLE_MAPS_API_KEY environment variable
search_placesboolTrueEnable the search_places tool.
get_directionsboolTrueEnable the get_directions tool.
validate_addressboolTrueEnable the validate_address tool.
geocode_addressboolTrueEnable the geocode_address tool.
reverse_geocodeboolTrueEnable the reverse_geocode tool.
get_distance_matrixboolTrueEnable the get_distance_matrix tool.
get_elevationboolTrueEnable the get_elevation tool.
get_timezoneboolTrueEnable the get_timezone tool.

Toolkit Functions

FunctionDescription
search_placesSearch for places using Google Maps Places API. Parameters: query (str) for the search query. Returns stringified JSON with place details including name, address, phone, website, rating, and hours.
get_directionsGet directions between locations. Parameters: origin (str), destination (str), optional mode (str) for travel mode, optional departure_time (datetime), optional avoid (List[str]) for features to avoid. Returns route information.
validate_addressValidate an address. Parameters: address (str), region_code (str, default "US"), optional locality (str), enable_usps_cass (bool, default False). Returns address validation results.
geocode_addressConvert address to coordinates. Parameters: address (str), optional region (str). Returns location information with coordinates.
reverse_geocodeConvert coordinates to address. Parameters: lat (float), lng (float), optional result_type and location_type (List[str]). Returns address information.
get_distance_matrixCalculate distances between locations. Parameters: origins (List[str]), destinations (List[str]), optional mode (str), departure_time (datetime), and avoid (List[str]). Returns distance and duration matrix.
get_elevationGet elevation for a location. Parameters: lat (float), lng (float). Returns elevation data.
get_timezoneGet timezone for a location. Parameters: lat (float), lng (float), optional timestamp (datetime). Returns timezone information.

You can use include_tools or exclude_tools to modify the list of tools the agent has access to. Learn more about selecting tools.

Rate Limits

Google Maps APIs have usage limits and quotas that vary by service and billing plan. Please refer to the Google Maps Platform pricing for details.

Developer Resources