> ## Documentation Index
> Fetch the complete documentation index at: https://langchain-zh.cn/llms.txt
> Use this file to discover all available pages before exploring further.

# Google Places 集成

> 使用 LangChain JavaScript 集成 Google Places 工具。

Google Places 工具允许您的代理利用 Google Places API，从 Google Places 上列出的地点相关文本中查找地址、电话号码、网站等信息。

## 设置

您需要从 [Google 此处](https://developers.google.com/maps/documentation/places/web-service/overview) 获取 API 密钥，并 [启用新的 Places API](https://console.cloud.google.com/apis/library/places.googleapis.com)。然后，将您的 API 密钥设置为 `process.env.GOOGLE_PLACES_API_KEY` 或作为 `apiKey` 构造函数参数传入。

## 使用

<Tip>
  有关安装 LangChain 包的通用说明，请参阅 [此部分](/oss/javascript/langchain/install)。
</Tip>

```bash npm theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
npm install @langchain/openai @langchain/community @langchain/core
```

```typescript theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
import { GooglePlacesAPI } from "@langchain/community/tools/google_places";
import { OpenAI } from "@langchain/openai";
import { initializeAgentExecutorWithOptions } from "@langchain/classic/agents";

export async function run() {
  const model = new OpenAI({
    temperature: 0,
  });

  const tools = [new GooglePlacesAPI()];

  const executor = await initializeAgentExecutorWithOptions(tools, model, {
    agentType: "zero-shot-react-description",
    verbose: true,
  });

  const res = await executor.invoke({
    input: "多伦多大学士嘉堡校区在哪里？",
  });

  console.log(res.output);
}
```

## 相关链接

* 工具 [概念指南](/oss/javascript/langchain/tools)
* 工具 [操作指南](/oss/javascript/langchain/tools)

***

<div className="source-links">
  <Callout icon="edit">
    [Edit this page on GitHub](https://github.com/langchain-ai/docs/edit/main/src/i18n\zh-CN\oss\javascript\integrations\tools\google_places.mdx) or [file an issue](https://github.com/langchain-ai/docs/issues/new/choose).
  </Callout>

  <Callout icon="terminal-2">
    [Connect these docs](/use-these-docs) to Claude, VSCode, and more via MCP for real-time answers.
  </Callout>
</div>
