angular-google-maps
AngularアプリにGoogleマップを組み込み、マーカーや図形、イベント処理など、インタラクティブな地図機能を実装するSkill。
📜 元の英語説明(参考)
Angular Google Maps (@angular/google-maps) integration for interactive map features. Use when embedding Google Maps, adding markers, polylines, polygons, info windows, or implementing map controls and event handling in Angular applications. Supports clustering, heatmaps, and drawing tools.
🇯🇵 日本人クリエイター向け解説
AngularアプリにGoogleマップを組み込み、マーカーや図形、イベント処理など、インタラクティブな地図機能を実装するSkill。
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-17
- 取得日時
- 2026-05-17
- 同梱ファイル
- 1
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
[Skill 名] angular-google-maps
Angular Google Maps スキル
ルール
セットアップと設定
@angular/google-mapsからGoogleMapsModuleをインポートします。index.htmlで API キーを使って Google Maps スクリプトを読み込みます。- TypeScript の型には
@types/google.mapsを使用します。 - セキュリティのために、API キーをドメイン/IP で制限します。
マップコンポーネント
<google-map>コンポーネントを[center]、[zoom]、[options]バインディングと共に使用します。google-map要素に明示的な高さを設定します(表示に必須です)。- 位置には
google.maps.LatLngLiteral型を使用します:{ lat: number, lng: number }。 - マップイベントを処理します:
(mapClick)、(mapDrag)、(zoomChanged)。
マーカー
<google-map>内で<map-marker>コンポーネントを使用します。- マーカーのプロパティを設定します:
[position]、[label]、[title]、[options]。 - マーカーイベントを処理します:
(mapClick)、(mapDragend)。 - 100 を超えるマーカーにはマーカークラスタリングを使用します。
情報ウィンドウ
- マーカーのポップアップには
<map-info-window>コンポーネントを使用します。 @ViewChild(MapInfoWindow)を使用して情報ウィンドウを参照します。- 表示するには
infoWindow.open()を呼び出し、非表示にするにはinfoWindow.close()を呼び出します。 - 選択されたマーカーに基づいて情報ウィンドウのコンテンツを条件付きで表示します。
描画ツール
- ポリゴン形状には
[paths]と[options]を持つ<map-polygon>を使用します。 - 線には
[path]と[options]を持つ<map-polyline>を使用します。 - 円には
[center]、[radius]、[options]を持つ<map-circle>を使用します。 - スタイルを設定します:
fillColor、strokeColor、opacity、strokeWeight。
ジオコーディング
- 住所/座標変換には
google.maps.Geocoderを使用します。 - 繰り返しの API 呼び出しを避けるために、ジオコーディング結果をキャッシュします。
- ユーザー入力に対してジオコーディングリクエストをデバウンスします (300-500ms)。
- ジオコーディングエラーを適切に処理します。
パフォーマンス
- Google Maps スクリプトは必要なときにのみ遅延ロードします。
- 大規模なデータセット(100 を超えるマーカー)にはマーカークラスタリングを使用します。
- ビューポートの境界でマーカーをフィルタリングします。
- 大規模なデータセットの場合、すべてのマーカーを一度にロードすることは絶対に避けてください。
- デバウンスなしで、キーストロークごとにジオコーディングすることは絶対に避けてください。
セキュリティ
- 制限なしにクライアントコードで API キーを公開することは絶対に避けてください。
- API キーは環境設定に保存します。
- Google Cloud Console の API 制限(HTTP リファラー、API スコープ)を有効にします。
コンテキスト
概要
Angular Google Maps は、Google Maps JavaScript API の公式 Angular バインディングを提供し、マーカー、ポリゴン、情報ウィンドウ、ジオコーディングサービスとの宣言的なマップ統合を可能にします。
このスキルを使用するタイミング
以下の必要がある場合にこのスキルをアクティブにしてください。
- Angular コンポーネントに Google マップを埋め込む
- マップマーカーを追加し、カスタマイズする
- ポリライン、ポリゴン、円を描画する
- 情報ウィンドウとカスタムオーバーレイを実装する
- マップイベント(クリック、ドラッグ、ズーム)を処理する
- マーカークラスタリングを実装する
- ヒートマップレイヤーを追加する
- Google Maps 描画ツールを使用する
- 住所をジオコーディングし、座標を逆ジオコーディングする
- 大規模なデータセットのマップパフォーマンスを最適化する
インストール
npm install @angular/google-maps
# TypeScript の型
npm install @types/google.maps
セットアップ手順
API キーの取得
- Google Cloud Console にアクセスします。
- プロジェクトを作成または選択します。
- Maps JavaScript API を有効にします。
- API キーの認証情報を作成します。
- API キーを制限します(推奨)。
Google Maps スクリプトの読み込み
<!-- index.html -->
<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY"></script>
基本的なマップコンポーネントの例
import { Component } from '@angular/core';
import { GoogleMapsModule } from '@angular/google-maps';
@Component({
selector: 'app-map',
standalone: true,
imports: [GoogleMapsModule],
template: `
<google-map
[center]="center"
[zoom]="zoom"
[options]="options"
(mapClick)="onMapClick($event)">
<map-marker
*ngFor="let marker of markers"
[position]="marker.position"
[label]="marker.label"
[title]="marker.title"
(mapClick)="onMarkerClick(marker)">
</map-marker>
</google-map>
`,
styles: [`
google-map {
height: 400px;
width: 100%;
}
`]
})
export class MapComponent {
center: google.maps.LatLngLiteral = { lat: 25.033, lng: 121.565 }; // Taipei
zoom = 12;
options: google.maps.MapOptions = {
mapTypeId: 'roadmap',
disableDefaultUI: false,
zoomControl: true,
scrollwheel: true
};
markers: Marker[] = [
{ position: { lat: 25.033, lng: 121.565 }, label: 'A', title: 'Taipei 101' }
];
onMapClick(event: google.maps.MapMouseEvent) {
if (event.latLng) {
const newMarker = {
position: event.latLng.toJSON(),
label: String.fromCharCode(65 + this.markers.length),
title: 'New Location'
};
this.markers.push(newMarker);
}
}
onMarkerClick(marker: Marker) {
console.log('Marker clicked:', marker);
}
}
interface Marker {
position: google.maps.LatLngLiteral;
label?: string;
title?: string;
}
情報ウィンドウ付きマップの例
@Component({
template: `
<google-map [center]="center" [zoom]="zoom">
<map-marker
*ngFor="let marker of markers"
[position]="marker.position"
(mapClick)="openInfo(marker, infoWindow)">
</map-marker>
<map-info-window #infoWindow>
<div *ngIf="selectedMarker">
<h3>{{ selectedMarker.title }}</h3>
<p>{{ selectedMarker.description }}</p>
</div>
</map-info-window>
</google-map>
`
})
export class MapWithInfoComponent {
@ViewChild(MapInfoWindow) infoWindow!: MapInfoWindow;
selectedMarker: any;
openInfo(marker: any, infoWindow: MapInfoWindow) {
this.selectedMarker = marker;
infoWindow.open();
}
}
マーカークラスタリングの例
import { MarkerClusterer } from '@googlemaps/markerclusterer';
@Component({
template: `
<google-map #map [center]="center" [zoom]="zoom">
<map-marker
*ngFor="let marker of markers"
[position]="marker.position">
</map-marker>
</google-map>
`
})
export class ClusteredMapComponent implements AfterViewInit {
@ViewChild('map') mapComponent!: 📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
Angular Google Maps Skill
Rules
Setup and Configuration
- Import
GoogleMapsModulefrom@angular/google-maps - Load Google Maps script in
index.htmlwith API key - Use
@types/google.mapsfor TypeScript types - Restrict API key by domain/IP for security
Map Component
- Use
<google-map>component with[center],[zoom],[options]bindings - Set explicit height on
google-mapelement (required for display) - Use
google.maps.LatLngLiteraltype for positions:{ lat: number, lng: number } - Handle map events:
(mapClick),(mapDrag),(zoomChanged)
Markers
- Use
<map-marker>component inside<google-map> - Set marker properties:
[position],[label],[title],[options] - Handle marker events:
(mapClick),(mapDragend) - Use marker clustering for more than 100 markers
Info Windows
- Use
<map-info-window>component for marker popups - Reference info window using
@ViewChild(MapInfoWindow) - Call
infoWindow.open()to display,infoWindow.close()to hide - Show info window content conditionally based on selected marker
Drawing Tools
- Use
<map-polygon>for polygon shapes with[paths]and[options] - Use
<map-polyline>for lines with[path]and[options] - Use
<map-circle>for circles with[center],[radius],[options] - Configure styles:
fillColor,strokeColor,opacity,strokeWeight
Geocoding
- Use
google.maps.Geocoderfor address/coordinate conversion - Cache geocoding results to avoid repeated API calls
- Debounce geocoding requests (300-500ms) for user input
- Handle geocoding errors gracefully
Performance
- Lazy load Google Maps script only when needed
- Use marker clustering for large datasets (>100 markers)
- Filter markers by viewport bounds
- NEVER load all markers at once for large datasets
- NEVER geocode on every keystroke without debouncing
Security
- NEVER expose API key in client code without restrictions
- Store API key in environment configuration
- Enable Google Cloud Console API restrictions (HTTP referrers, API scope)
Context
Summary
Angular Google Maps provides official Angular bindings for Google Maps JavaScript API, enabling declarative map integration with markers, polygons, info windows, and geocoding services.
When to Use This Skill
Activate this skill when you need to:
- Embed Google Maps in Angular components
- Add and customize map markers
- Draw polylines, polygons, and circles
- Implement info windows and custom overlays
- Handle map events (click, drag, zoom)
- Implement marker clustering
- Add heatmap layers
- Use Google Maps drawing tools
- Geocode addresses and reverse geocode coordinates
- Optimize map performance for large datasets
Installation
npm install @angular/google-maps
# Types for TypeScript
npm install @types/google.maps
Setup Steps
Get API Key
- Go to Google Cloud Console
- Create or select a project
- Enable Maps JavaScript API
- Create API key credentials
- Restrict API key (recommended)
Load Google Maps Script
<!-- index.html -->
<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY"></script>
Basic Map Component Example
import { Component } from '@angular/core';
import { GoogleMapsModule } from '@angular/google-maps';
@Component({
selector: 'app-map',
standalone: true,
imports: [GoogleMapsModule],
template: `
<google-map
[center]="center"
[zoom]="zoom"
[options]="options"
(mapClick)="onMapClick($event)">
<map-marker
*ngFor="let marker of markers"
[position]="marker.position"
[label]="marker.label"
[title]="marker.title"
(mapClick)="onMarkerClick(marker)">
</map-marker>
</google-map>
`,
styles: [`
google-map {
height: 400px;
width: 100%;
}
`]
})
export class MapComponent {
center: google.maps.LatLngLiteral = { lat: 25.033, lng: 121.565 }; // Taipei
zoom = 12;
options: google.maps.MapOptions = {
mapTypeId: 'roadmap',
disableDefaultUI: false,
zoomControl: true,
scrollwheel: true
};
markers: Marker[] = [
{ position: { lat: 25.033, lng: 121.565 }, label: 'A', title: 'Taipei 101' }
];
onMapClick(event: google.maps.MapMouseEvent) {
if (event.latLng) {
const newMarker = {
position: event.latLng.toJSON(),
label: String.fromCharCode(65 + this.markers.length),
title: 'New Location'
};
this.markers.push(newMarker);
}
}
onMarkerClick(marker: Marker) {
console.log('Marker clicked:', marker);
}
}
interface Marker {
position: google.maps.LatLngLiteral;
label?: string;
title?: string;
}
Map with Info Window Example
@Component({
template: `
<google-map [center]="center" [zoom]="zoom">
<map-marker
*ngFor="let marker of markers"
[position]="marker.position"
(mapClick)="openInfo(marker, infoWindow)">
</map-marker>
<map-info-window #infoWindow>
<div *ngIf="selectedMarker">
<h3>{{ selectedMarker.title }}</h3>
<p>{{ selectedMarker.description }}</p>
</div>
</map-info-window>
</google-map>
`
})
export class MapWithInfoComponent {
@ViewChild(MapInfoWindow) infoWindow!: MapInfoWindow;
selectedMarker: any;
openInfo(marker: any, infoWindow: MapInfoWindow) {
this.selectedMarker = marker;
infoWindow.open();
}
}
Marker Clustering Example
import { MarkerClusterer } from '@googlemaps/markerclusterer';
@Component({
template: `
<google-map #map [center]="center" [zoom]="zoom">
<map-marker
*ngFor="let marker of markers"
[position]="marker.position">
</map-marker>
</google-map>
`
})
export class ClusteredMapComponent implements AfterViewInit {
@ViewChild('map') mapComponent!: GoogleMap;
markers: Marker[] = [];
ngAfterViewInit() {
if (this.mapComponent.googleMap) {
const markerClusterer = new MarkerClusterer({
map: this.mapComponent.googleMap,
markers: this.getGoogleMarkers()
});
}
}
private getGoogleMarkers(): google.maps.Marker[] {
return this.markers.map(m =>
new google.maps.Marker({ position: m.position })
);
}
}
Drawing Tools Example
@Component({
template: `
<google-map [center]="center" [zoom]="zoom">
<map-polygon
[paths]="polygonPaths"
[options]="polygonOptions">
</map-polygon>
<map-polyline
[path]="polylinePath"
[options]="polylineOptions">
</map-polyline>
<map-circle
[center]="circleCenter"
[radius]="circleRadius"
[options]="circleOptions">
</map-circle>
</google-map>
`
})
export class DrawingMapComponent {
polygonPaths: google.maps.LatLngLiteral[] = [
{ lat: 25.033, lng: 121.565 },
{ lat: 25.035, lng: 121.567 },
{ lat: 25.031, lng: 121.569 }
];
polygonOptions: google.maps.PolygonOptions = {
fillColor: '#FF0000',
fillOpacity: 0.3,
strokeColor: '#FF0000',
strokeOpacity: 1,
strokeWeight: 2
};
polylinePath: google.maps.LatLngLiteral[] = [
{ lat: 25.030, lng: 121.560 },
{ lat: 25.035, lng: 121.565 }
];
polylineOptions: google.maps.PolylineOptions = {
strokeColor: '#0000FF',
strokeOpacity: 1.0,
strokeWeight: 3
};
circleCenter: google.maps.LatLngLiteral = { lat: 25.033, lng: 121.565 };
circleRadius = 1000; // meters
circleOptions: google.maps.CircleOptions = {
fillColor: '#00FF00',
fillOpacity: 0.2,
strokeColor: '#00FF00',
strokeOpacity: 0.8,
strokeWeight: 2
};
}
Geocoding Service Example
import { Injectable } from '@angular/core';
import { Observable, from } from 'rxjs';
import { map } from 'rxjs/operators';
@Injectable({ providedIn: 'root' })
export class GeocodingService {
private geocoder = new google.maps.Geocoder();
geocodeAddress(address: string): Observable<google.maps.LatLngLiteral | null> {
return from(
this.geocoder.geocode({ address })
).pipe(
map(response => {
if (response.results && response.results[0]) {
const location = response.results[0].geometry.location;
return { lat: location.lat(), lng: location.lng() };
}
return null;
})
);
}
reverseGeocode(location: google.maps.LatLngLiteral): Observable<string | null> {
return from(
this.geocoder.geocode({ location })
).pipe(
map(response => {
if (response.results && response.results[0]) {
return response.results[0].formatted_address;
}
return null;
})
);
}
}