@eddaic/nestjs-google-maps

中文文档
6.1.0发布于 2026/10/23ISCTypeScriptCommonJS构建来源已验证近 30 天下载 2272

NestJS Google Maps API client with convenience methods for places, reverse geocoding, geolocation, elevation, and time zones.

原始使用文档
文档目录5 节
  1. Compatibility
  2. Installation
  3. Usage
  4. Initializing
  5. Calling

nestjs-google-maps

A NestJS module for configuring a Google Maps Services JS client through dependency injection. It includes convenience methods for place details, reverse geocoding, geolocation, elevation, and time zones, with direct access to the underlying client.

Compatibility

Supports NestJS 11 and 12 in CommonJS and ESM applications. Published JavaScript is CommonJS with TypeScript declarations; ESM applications can use named imports. NestJS 12 requires Node.js 20.19+ (22.12+ on Node 22); Node.js 24 is recommended.

Installation

npm install @eddaic/nestjs-google-maps @nestjs/config

Usage

Initializing

import { GoogleMapsModule } from '@eddaic/nestjs-google-maps';
import { Module } from '@nestjs/common';
import { ConfigModule, ConfigService } from '@nestjs/config';

@Module({
  imports: [
    ConfigModule.forRoot({ isGlobal: true }),
    GoogleMapsModule.registerAsync({
      inject: [ConfigService],
      useFactory: (config: ConfigService) => ({
        params: { key: config.getOrThrow<string>('GOOGLE_API_KEY') },
      }),
    }),
  ],
})
export class AppModule {}

Calling

Register this service in your application's providers.

import { GoogleMapsService } from '@eddaic/nestjs-google-maps';
import { Injectable } from '@nestjs/common';

@Injectable()
export class AppService {
  constructor(private readonly maps: GoogleMapsService) {}

  async lookup(place_id: string, points: { lat: number; lng: number }[]) {
    // Some convenience methods are included
    const placeDetails = await this.maps.placeDetails({ place_id });

    // Otherwise can access the client directly for full set of APIs
    const params = { ...this.maps.params, points };
    const response = await this.maps.client.nearestRoads({ params });
    return { placeDetails, roads: response.data };
  }
}

版本与发布记录

@eddaic/nestjs-google-maps 共发布 23 个版本,首次发布于 2024/09/28;过去 12 个月发布了 6 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
6.1.0latest2026/10/2321 天前
6.0.02026/10/2321 天前
5.5.22026/09/012 个月前
5.5.02026/04/087 个月前
5.4.22026/01/269 个月前
5.3.02025/12/0511 个月前

关于 @eddaic/nestjs-google-maps 的常见问题

@eddaic/nestjs-google-maps 是什么?

NestJS Google Maps API client with convenience methods for places, reverse geocoding, geolocation, elevation, and time zones.

如何安装 @eddaic/nestjs-google-maps?

在项目目录运行 npm install @eddaic/nestjs-google-maps,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@nestjs/common(^11.0.0 || ^12.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@eddaic/nestjs-google-maps 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@eddaic/nestjs-google-maps 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@eddaic/nestjs-google-maps 可以商用吗?

@eddaic/nestjs-google-maps 使用 ISC 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@eddaic/nestjs-google-maps 的下载量有多少?

根据 npm 官方下载统计,@eddaic/nestjs-google-maps 在 2026/10/13 – 2026/11/11 这 30 天内被下载 2,272 次,日均约 76 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@eddaic/nestjs-google-maps 还在维护吗?

最新版本 6.1.0 发布于 2026/10/23(21 天前);至今共发布 23 个版本,其中过去 12 个月发布了 6 个;首次发布于 2024/09/28。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。