Class GoogleMapsTool

java.lang.Object
com.google.adk.tools.BaseTool
com.google.adk.tools.GoogleMapsTool

public class GoogleMapsTool extends BaseTool
A built-in tool that is automatically invoked by Gemini 2 models to retrieve search results from Google Maps.

This tool operates internally within the model and does not require or perform local code execution.

Usage example in an LlmAgent:

LlmAgent agent = LlmAgent.builder()
    .addTool(new GoogleMapsTool())
    .build();

You can pass specific latitude and longitude coordinates, via the generateContentConfig() method of the `LlmAgent` build:

LlmAgent agent = LlmAgent.builder()
  .addTool(new GoogleMapsTool())
  .generateContentConfig(GenerateContentConfig.builder()
    .toolConfig(ToolConfig.builder()
        .retrievalConfig(RetrievalConfig.builder()
            .latLng(LatLng.builder()
                .latitude(latitude)
                .longitude(longitude)
                .build())
            .build())
        .build())
    .build())
  .build();
  • Field Details

  • Constructor Details

    • GoogleMapsTool

      public GoogleMapsTool()
  • Method Details

    • processLlmRequest

      public io.reactivex.rxjava3.core.Completable processLlmRequest(LlmRequest.Builder llmRequestBuilder, ToolContext toolContext)
      Description copied from class: BaseTool
      Processes the outgoing LlmRequest.Builder.

      This implementation adds the current tool's BaseTool.declaration() to the GenerateContentConfig within the builder. If a tool with function declarations already exists, the current tool's declaration is merged into it. Otherwise, a new tool definition with the current tool's declaration is created. The current tool itself is also added to the builder's internal list of tools. Override this method for processing the outgoing request.

      Overrides:
      processLlmRequest in class BaseTool