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 library and an API key which can be obtained from the Google Cloud Console.

pip install googlemaps
export GOOGLE_MAPS_API_KEY=your_api_key_here

You’ll need to enable the following APIs in your Google Cloud Console:

  • Places API
  • Directions API
  • Geocoding API
  • Address Validation API
  • Distance Matrix API
  • Elevation API
  • Time Zone API

Example

Basic usage of the Google Maps toolkit:

from agno.agent import Agent
from agno.tools.google_maps import GoogleMapTools

agent = Agent(tools=[GoogleMapTools()], show_tool_calls=True)
agent.print_response("Find coffee shops in San Francisco")

For more examples, see the Google Maps Tools Examples.

Toolkit Params

ParameterTypeDefaultDescription
keyOptional[str]NoneOptional API key. If not provided, uses GOOGLE_MAPS_API_KEY environment variable
search_placesboolTrueEnable places search functionality
get_directionsboolTrueEnable directions functionality
validate_addressboolTrueEnable address validation functionality
geocode_addressboolTrueEnable geocoding functionality
reverse_geocodeboolTrueEnable reverse geocoding functionality
get_distance_matrixboolTrueEnable distance matrix functionality
get_elevationboolTrueEnable elevation functionality
get_timezoneboolTrueEnable timezone functionality

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 avoid (List[str]) for features to avoid. Returns route information.
validate_addressValidate an address. Parameters: address (str), optional region_code (str), optional locality (str). 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) 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.

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