@gui-chat-plugin/google-map 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +126 -0
- package/dist/core/definition.d.ts +66 -0
- package/dist/core/definition.d.ts.map +1 -0
- package/dist/core/index.d.ts +5 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/plugin.d.ts +9 -0
- package/dist/core/plugin.d.ts.map +1 -0
- package/dist/core/samples.d.ts +3 -0
- package/dist/core/samples.d.ts.map +1 -0
- package/dist/core/types.d.ts +75 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core.cjs +76 -0
- package/dist/core.js +458 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/style.css +1 -0
- package/dist/vue/Preview.vue.d.ts +9 -0
- package/dist/vue/Preview.vue.d.ts.map +1 -0
- package/dist/vue/View.vue.d.ts +11 -0
- package/dist/vue/View.vue.d.ts.map +1 -0
- package/dist/vue/index.d.ts +15 -0
- package/dist/vue/index.d.ts.map +1 -0
- package/dist/vue.cjs +1 -0
- package/dist/vue.js +516 -0
- package/package.json +57 -0
package/README.md
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# @gui-chat-plugin/google-map
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@gui-chat-plugin/google-map)
|
|
4
|
+
|
|
5
|
+
Google Map location plugin for GUI Chat applications. Display locations on an interactive map.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- Show any location by name or address
|
|
10
|
+
- Google Maps embed integration
|
|
11
|
+
- Fallback link to open in Google Maps
|
|
12
|
+
- Support for coordinates (lat/lng)
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
yarn add @gui-chat-plugin/google-map
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
### Vue Integration
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
// In src/tools/index.ts
|
|
26
|
+
import MapPlugin from "@gui-chat-plugin/google-map/vue";
|
|
27
|
+
|
|
28
|
+
const pluginList = [
|
|
29
|
+
// ... other plugins
|
|
30
|
+
MapPlugin,
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
// In src/main.ts
|
|
34
|
+
import "@gui-chat-plugin/google-map/style.css";
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Core-only Usage
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
import { executeMap, TOOL_DEFINITION } from "@gui-chat-plugin/google-map";
|
|
41
|
+
|
|
42
|
+
// Show a location
|
|
43
|
+
const result = await executeMap(context, {
|
|
44
|
+
location: "Tokyo Tower, Japan",
|
|
45
|
+
});
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## API
|
|
49
|
+
|
|
50
|
+
### MapArgs
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
interface MapArgs {
|
|
54
|
+
location: string; // Location name, address, or coordinates
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### MapToolData
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
interface MapToolData {
|
|
62
|
+
location: string | { lat: number; lng: number };
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Google Maps API Setup
|
|
67
|
+
|
|
68
|
+
This plugin requires a Google Maps API key with the **Maps Embed API** enabled.
|
|
69
|
+
|
|
70
|
+
### Step 1: Create a Google Cloud Project
|
|
71
|
+
|
|
72
|
+
1. Go to [Google Cloud Console](https://console.cloud.google.com/)
|
|
73
|
+
2. Create a new project or select an existing one
|
|
74
|
+
3. Make sure billing is enabled for the project
|
|
75
|
+
|
|
76
|
+
### Step 2: Enable Maps Embed API
|
|
77
|
+
|
|
78
|
+
1. Go to [APIs & Services > Library](https://console.cloud.google.com/apis/library)
|
|
79
|
+
2. Search for "Maps Embed API"
|
|
80
|
+
3. Click on **Maps Embed API**
|
|
81
|
+
4. Click **Enable**
|
|
82
|
+
|
|
83
|
+
### Step 3: Create an API Key
|
|
84
|
+
|
|
85
|
+
1. Go to [APIs & Services > Credentials](https://console.cloud.google.com/apis/credentials)
|
|
86
|
+
2. Click **Create Credentials** > **API key**
|
|
87
|
+
3. Copy the generated API key
|
|
88
|
+
4. (Recommended) Click **Edit API key** to add restrictions:
|
|
89
|
+
- **Application restrictions**: HTTP referrers (for web apps)
|
|
90
|
+
- **API restrictions**: Restrict to "Maps Embed API"
|
|
91
|
+
|
|
92
|
+
### Step 4: Configure the Plugin
|
|
93
|
+
|
|
94
|
+
Pass the API key via the `googleMapKey` prop to the view component, or configure it in your app's environment variables / start response.
|
|
95
|
+
|
|
96
|
+
```env
|
|
97
|
+
GOOGLE_MAP_API_KEY=your_api_key_here
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Development
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
# Install dependencies
|
|
104
|
+
yarn install
|
|
105
|
+
|
|
106
|
+
# Run demo
|
|
107
|
+
yarn dev
|
|
108
|
+
|
|
109
|
+
# Build
|
|
110
|
+
yarn build
|
|
111
|
+
|
|
112
|
+
# Lint
|
|
113
|
+
yarn lint
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Test Prompts
|
|
117
|
+
|
|
118
|
+
Try these prompts to test the plugin:
|
|
119
|
+
|
|
120
|
+
1. "Show me the Eiffel Tower on the map"
|
|
121
|
+
2. "Where is the Sydney Opera House located?"
|
|
122
|
+
3. "Display Tokyo Station on the map"
|
|
123
|
+
|
|
124
|
+
## License
|
|
125
|
+
|
|
126
|
+
MIT
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
export declare const TOOL_NAME = "mapControl";
|
|
2
|
+
export declare const TOOL_DEFINITION: {
|
|
3
|
+
type: "function";
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
parameters: {
|
|
7
|
+
type: "object";
|
|
8
|
+
properties: {
|
|
9
|
+
action: {
|
|
10
|
+
type: string;
|
|
11
|
+
enum: string[];
|
|
12
|
+
description: string;
|
|
13
|
+
};
|
|
14
|
+
location: {
|
|
15
|
+
type: string;
|
|
16
|
+
description: string;
|
|
17
|
+
};
|
|
18
|
+
lat: {
|
|
19
|
+
type: string;
|
|
20
|
+
description: string;
|
|
21
|
+
};
|
|
22
|
+
lng: {
|
|
23
|
+
type: string;
|
|
24
|
+
description: string;
|
|
25
|
+
};
|
|
26
|
+
zoom: {
|
|
27
|
+
type: string;
|
|
28
|
+
minimum: number;
|
|
29
|
+
maximum: number;
|
|
30
|
+
description: string;
|
|
31
|
+
};
|
|
32
|
+
searchQuery: {
|
|
33
|
+
type: string;
|
|
34
|
+
description: string;
|
|
35
|
+
};
|
|
36
|
+
placeType: {
|
|
37
|
+
type: string;
|
|
38
|
+
enum: string[];
|
|
39
|
+
description: string;
|
|
40
|
+
};
|
|
41
|
+
origin: {
|
|
42
|
+
type: string;
|
|
43
|
+
description: string;
|
|
44
|
+
};
|
|
45
|
+
destination: {
|
|
46
|
+
type: string;
|
|
47
|
+
description: string;
|
|
48
|
+
};
|
|
49
|
+
travelMode: {
|
|
50
|
+
type: string;
|
|
51
|
+
enum: string[];
|
|
52
|
+
description: string;
|
|
53
|
+
};
|
|
54
|
+
markerTitle: {
|
|
55
|
+
type: string;
|
|
56
|
+
description: string;
|
|
57
|
+
};
|
|
58
|
+
markerLabel: {
|
|
59
|
+
type: string;
|
|
60
|
+
description: string;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
required: never[];
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
//# sourceMappingURL=definition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../../src/core/definition.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,eAAe,CAAC;AAEtC,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4L3B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ToolContext, ToolResult, ToolPluginCore } from "gui-chat-protocol";
|
|
2
|
+
import type { MapToolData, MapArgs, MapJsonData } from "./types";
|
|
3
|
+
import { TOOL_NAME, TOOL_DEFINITION } from "./definition";
|
|
4
|
+
export declare const executeMapControl: (__context: ToolContext, args: MapArgs) => Promise<ToolResult<MapToolData, MapJsonData>>;
|
|
5
|
+
export declare const systemPrompt = "You have access to the mapControl tool for interactive map operations.\n\n## Basic Usage\n\nShow a location:\n```\nmapControl(location: \"Tokyo Station\")\nmapControl(action: \"showLocation\", location: \"Paris, France\")\n```\n\n## Available Actions\n\n### showLocation (default)\nDisplay a location on the map with a marker.\n- Use `location` for place names/addresses\n- Or use `lat` and `lng` for coordinates\n\n### setCenter\nMove the map center without adding markers.\n```\nmapControl(action: \"setCenter\", location: \"Shibuya, Tokyo\")\n```\n\n### setZoom\nChange the zoom level (1-21).\n- 1-5: Continent/Country level\n- 6-10: Region/City level\n- 11-15: Street level\n- 16-21: Building level\n```\nmapControl(action: \"setZoom\", zoom: 12)\n```\n\n### addMarker\nAdd a marker at a location (without centering).\n```\nmapControl(action: \"addMarker\", location: \"Tokyo Tower\", markerTitle: \"Tokyo Tower\", markerLabel: \"T\")\n```\n\n### clearMarkers\nRemove all markers from the map.\n```\nmapControl(action: \"clearMarkers\")\n```\n\n### findPlaces\nSearch for nearby places using Google Places API.\n```\nmapControl(action: \"findPlaces\", searchQuery: \"ramen\")\nmapControl(action: \"findPlaces\", placeType: \"restaurant\")\nmapControl(action: \"findPlaces\", searchQuery: \"coffee\", placeType: \"cafe\")\n```\n\n### getDirections\nGet directions between two locations.\n```\nmapControl(action: \"getDirections\", origin: \"Tokyo Station\", destination: \"Tokyo Tower\", travelMode: \"WALKING\")\n```\nTravel modes: DRIVING, WALKING, BICYCLING, TRANSIT\n\n## Response Data\n\nThe map will return JSON data with the results of each action, including:\n- Current center coordinates and zoom level\n- Markers on the map\n- Place search results with ratings and addresses\n- Route information with distance and duration";
|
|
6
|
+
export declare const pluginCore: ToolPluginCore<MapToolData, MapJsonData, MapArgs>;
|
|
7
|
+
export { TOOL_NAME, TOOL_DEFINITION };
|
|
8
|
+
export declare const executeMap: (__context: ToolContext, args: MapArgs) => Promise<ToolResult<MapToolData, MapJsonData>>;
|
|
9
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/core/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,cAAc,EACf,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAa,WAAW,EAAE,MAAM,SAAS,CAAC;AAC5E,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AA2B1D,eAAO,MAAM,iBAAiB,GAC5B,WAAW,WAAW,EACtB,MAAM,OAAO,KACZ,OAAO,CAAC,UAAU,CAAC,WAAW,EAAE,WAAW,CAAC,CAoG9C,CAAC;AAEF,eAAO,MAAM,YAAY,gzDAkEsB,CAAC;AAEhD,eAAO,MAAM,UAAU,EAAE,cAAc,CAAC,WAAW,EAAE,WAAW,EAAE,OAAO,CAOxE,CAAC;AAEF,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC;AACtC,eAAO,MAAM,UAAU,cAtLV,WAAW,QAChB,OAAO,KACZ,OAAO,CAAC,UAAU,CAAC,WAAW,EAAE,WAAW,CAAC,CAoLJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"samples.d.ts","sourceRoot":"","sources":["../../src/core/samples.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,eAAO,MAAM,OAAO,EAAE,UAAU,EAkI/B,CAAC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
export type MapAction = "showLocation" | "setCenter" | "setZoom" | "addMarker" | "clearMarkers" | "findPlaces" | "getDirections";
|
|
2
|
+
export type PlaceType = "accounting" | "airport" | "amusement_park" | "aquarium" | "art_gallery" | "atm" | "bakery" | "bank" | "bar" | "beauty_salon" | "bicycle_store" | "book_store" | "bowling_alley" | "bus_station" | "cafe" | "campground" | "car_dealer" | "car_rental" | "car_repair" | "car_wash" | "casino" | "cemetery" | "church" | "city_hall" | "clothing_store" | "convenience_store" | "courthouse" | "dentist" | "department_store" | "doctor" | "drugstore" | "electrician" | "electronics_store" | "embassy" | "fire_station" | "florist" | "funeral_home" | "furniture_store" | "gas_station" | "gym" | "hair_care" | "hardware_store" | "hindu_temple" | "home_goods_store" | "hospital" | "insurance_agency" | "jewelry_store" | "laundry" | "lawyer" | "library" | "light_rail_station" | "liquor_store" | "local_government_office" | "locksmith" | "lodging" | "meal_delivery" | "meal_takeaway" | "mosque" | "movie_rental" | "movie_theater" | "moving_company" | "museum" | "night_club" | "painter" | "park" | "parking" | "pet_store" | "pharmacy" | "physiotherapist" | "plumber" | "police" | "post_office" | "primary_school" | "real_estate_agency" | "restaurant" | "roofing_contractor" | "rv_park" | "school" | "secondary_school" | "shoe_store" | "shopping_mall" | "spa" | "stadium" | "storage" | "store" | "subway_station" | "supermarket" | "synagogue" | "taxi_stand" | "tourist_attraction" | "train_station" | "transit_station" | "travel_agency" | "university" | "veterinary_care" | "zoo";
|
|
3
|
+
export type TravelMode = "DRIVING" | "WALKING" | "BICYCLING" | "TRANSIT";
|
|
4
|
+
export interface LatLng {
|
|
5
|
+
lat: number;
|
|
6
|
+
lng: number;
|
|
7
|
+
}
|
|
8
|
+
export interface MarkerData {
|
|
9
|
+
id: string;
|
|
10
|
+
position: LatLng;
|
|
11
|
+
title?: string;
|
|
12
|
+
label?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface PlaceResult {
|
|
15
|
+
placeId: string;
|
|
16
|
+
name: string;
|
|
17
|
+
address: string;
|
|
18
|
+
location: LatLng;
|
|
19
|
+
rating?: number;
|
|
20
|
+
userRatingsTotal?: number;
|
|
21
|
+
types?: string[];
|
|
22
|
+
openNow?: boolean;
|
|
23
|
+
photoUrl?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface DirectionStep {
|
|
26
|
+
instruction: string;
|
|
27
|
+
distance: string;
|
|
28
|
+
duration: string;
|
|
29
|
+
travelMode: string;
|
|
30
|
+
}
|
|
31
|
+
export interface DirectionRoute {
|
|
32
|
+
summary: string;
|
|
33
|
+
distance: string;
|
|
34
|
+
duration: string;
|
|
35
|
+
startAddress: string;
|
|
36
|
+
endAddress: string;
|
|
37
|
+
steps: DirectionStep[];
|
|
38
|
+
polyline: string;
|
|
39
|
+
}
|
|
40
|
+
export interface MapToolData {
|
|
41
|
+
action: MapAction;
|
|
42
|
+
location?: string | LatLng;
|
|
43
|
+
zoom?: number;
|
|
44
|
+
marker?: MarkerData;
|
|
45
|
+
searchQuery?: string;
|
|
46
|
+
placeType?: PlaceType;
|
|
47
|
+
origin?: string | LatLng;
|
|
48
|
+
destination?: string | LatLng;
|
|
49
|
+
travelMode?: TravelMode;
|
|
50
|
+
}
|
|
51
|
+
export interface MapJsonData {
|
|
52
|
+
action: MapAction;
|
|
53
|
+
success: boolean;
|
|
54
|
+
center?: LatLng;
|
|
55
|
+
zoom?: number;
|
|
56
|
+
markers?: MarkerData[];
|
|
57
|
+
places?: PlaceResult[];
|
|
58
|
+
route?: DirectionRoute;
|
|
59
|
+
error?: string;
|
|
60
|
+
}
|
|
61
|
+
export interface MapArgs {
|
|
62
|
+
action?: MapAction;
|
|
63
|
+
location?: string;
|
|
64
|
+
lat?: number;
|
|
65
|
+
lng?: number;
|
|
66
|
+
zoom?: number;
|
|
67
|
+
searchQuery?: string;
|
|
68
|
+
placeType?: PlaceType;
|
|
69
|
+
origin?: string;
|
|
70
|
+
destination?: string;
|
|
71
|
+
travelMode?: TravelMode;
|
|
72
|
+
markerTitle?: string;
|
|
73
|
+
markerLabel?: string;
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AACA,MAAM,MAAM,SAAS,GACjB,cAAc,GACd,WAAW,GACX,SAAS,GACT,WAAW,GACX,cAAc,GACd,YAAY,GACZ,eAAe,CAAC;AAGpB,MAAM,MAAM,SAAS,GACjB,YAAY,GACZ,SAAS,GACT,gBAAgB,GAChB,UAAU,GACV,aAAa,GACb,KAAK,GACL,QAAQ,GACR,MAAM,GACN,KAAK,GACL,cAAc,GACd,eAAe,GACf,YAAY,GACZ,eAAe,GACf,aAAa,GACb,MAAM,GACN,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,UAAU,GACV,QAAQ,GACR,UAAU,GACV,QAAQ,GACR,WAAW,GACX,gBAAgB,GAChB,mBAAmB,GACnB,YAAY,GACZ,SAAS,GACT,kBAAkB,GAClB,QAAQ,GACR,WAAW,GACX,aAAa,GACb,mBAAmB,GACnB,SAAS,GACT,cAAc,GACd,SAAS,GACT,cAAc,GACd,iBAAiB,GACjB,aAAa,GACb,KAAK,GACL,WAAW,GACX,gBAAgB,GAChB,cAAc,GACd,kBAAkB,GAClB,UAAU,GACV,kBAAkB,GAClB,eAAe,GACf,SAAS,G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AClB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB"}
|
package/dist/core.cjs
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s="mapControl",c={type:"function",name:s,description:`Control a Google Map interactively. Supports showing locations, adding markers, searching for places, and getting directions.
|
|
2
|
+
|
|
3
|
+
Available actions:
|
|
4
|
+
- showLocation: Display a location on the map (default action)
|
|
5
|
+
- setCenter: Change the map center without markers
|
|
6
|
+
- setZoom: Change the zoom level (1-21)
|
|
7
|
+
- addMarker: Add a marker to the map
|
|
8
|
+
- clearMarkers: Remove all markers from the map
|
|
9
|
+
- findPlaces: Search for nearby places using Google Places API
|
|
10
|
+
- getDirections: Get directions between two locations`,parameters:{type:"object",properties:{action:{type:"string",enum:["showLocation","setCenter","setZoom","addMarker","clearMarkers","findPlaces","getDirections"],description:"The action to perform. Defaults to 'showLocation' if not specified."},location:{type:"string",description:"Location name, address, or place (e.g., 'Tokyo Station', 'Paris, France'). Used with showLocation, setCenter, addMarker actions."},lat:{type:"number",description:"Latitude coordinate. Can be used instead of location for precise positioning."},lng:{type:"number",description:"Longitude coordinate. Can be used instead of location for precise positioning."},zoom:{type:"integer",minimum:1,maximum:21,description:"Zoom level for setZoom action (1=world, 15=streets, 21=buildings). Default is 15."},searchQuery:{type:"string",description:"Text search query for findPlaces action (e.g., 'ramen', 'coffee shop')."},placeType:{type:"string",enum:["accounting","airport","amusement_park","aquarium","art_gallery","atm","bakery","bank","bar","beauty_salon","bicycle_store","book_store","bowling_alley","bus_station","cafe","campground","car_dealer","car_rental","car_repair","car_wash","casino","cemetery","church","city_hall","clothing_store","convenience_store","courthouse","dentist","department_store","doctor","drugstore","electrician","electronics_store","embassy","fire_station","florist","funeral_home","furniture_store","gas_station","gym","hair_care","hardware_store","hindu_temple","home_goods_store","hospital","insurance_agency","jewelry_store","laundry","lawyer","library","light_rail_station","liquor_store","local_government_office","locksmith","lodging","meal_delivery","meal_takeaway","mosque","movie_rental","movie_theater","moving_company","museum","night_club","painter","park","parking","pet_store","pharmacy","physiotherapist","plumber","police","post_office","primary_school","real_estate_agency","restaurant","roofing_contractor","rv_park","school","secondary_school","shoe_store","shopping_mall","spa","stadium","storage","store","subway_station","supermarket","synagogue","taxi_stand","tourist_attraction","train_station","transit_station","travel_agency","university","veterinary_care","zoo"],description:"Type of place to search for with findPlaces action. Use with or instead of searchQuery."},origin:{type:"string",description:"Starting point for getDirections action. Can be a place name or address."},destination:{type:"string",description:"End point for getDirections action. Can be a place name or address."},travelMode:{type:"string",enum:["DRIVING","WALKING","BICYCLING","TRANSIT"],description:"Travel mode for getDirections action. Defaults to DRIVING."},markerTitle:{type:"string",description:"Title for the marker (shown on hover) when using addMarker."},markerLabel:{type:"string",description:"Single character label displayed on the marker when using addMarker."}},required:[]}},d="showLocation",m=15,p="DRIVING",g=()=>`marker_${Date.now()}_${Math.random().toString(36).substring(2,9)}`,h=o=>Number.isInteger(o)&&o>=1&&o<=21,u=o=>!!(o.location||o.lat!==void 0&&o.lng!==void 0),y=o=>o.lat!==void 0&&o.lng!==void 0?{lat:o.lat,lng:o.lng}:o.location,n=async(o,e)=>{const a=e.action||d;switch(a){case"showLocation":case"setCenter":case"addMarker":{if(!u(e))throw new Error(`${a} requires either 'location' or both 'lat' and 'lng' parameters`);const t=y(e),i={action:a,location:t};a==="addMarker"&&(i.marker={id:g(),position:typeof t=="string"?{lat:0,lng:0}:t,title:e.markerTitle,label:e.markerLabel?.charAt(0)});const r=typeof t=="string"?t:`${t?.lat}, ${t?.lng}`;return{message:{showLocation:`Showing ${r} on the map`,setCenter:`Centering map on ${r}`,addMarker:`Adding marker at ${r}`}[a],data:i}}case"setZoom":{const t=e.zoom??m;if(!h(t))throw new Error("Zoom level must be an integer between 1 and 21");return{message:`Setting zoom level to ${t}`,data:{action:a,zoom:t}}}case"clearMarkers":return{message:"Clearing all markers from the map",data:{action:a}};case"findPlaces":{if(!e.searchQuery&&!e.placeType)throw new Error("findPlaces requires either 'searchQuery' or 'placeType' parameter");return{message:`Searching for ${e.searchQuery?`"${e.searchQuery}"`:e.placeType} nearby`,data:{action:a,searchQuery:e.searchQuery,placeType:e.placeType}}}case"getDirections":{if(!e.origin||!e.destination)throw new Error("getDirections requires both 'origin' and 'destination' parameters");const t=e.travelMode||p;return{message:`Getting ${t.toLowerCase()} directions from ${e.origin} to ${e.destination}`,data:{action:a,origin:e.origin,destination:e.destination,travelMode:t}}}default:throw new Error(`Unknown action: ${a}`)}},l=`You have access to the mapControl tool for interactive map operations.
|
|
11
|
+
|
|
12
|
+
## Basic Usage
|
|
13
|
+
|
|
14
|
+
Show a location:
|
|
15
|
+
\`\`\`
|
|
16
|
+
mapControl(location: "Tokyo Station")
|
|
17
|
+
mapControl(action: "showLocation", location: "Paris, France")
|
|
18
|
+
\`\`\`
|
|
19
|
+
|
|
20
|
+
## Available Actions
|
|
21
|
+
|
|
22
|
+
### showLocation (default)
|
|
23
|
+
Display a location on the map with a marker.
|
|
24
|
+
- Use \`location\` for place names/addresses
|
|
25
|
+
- Or use \`lat\` and \`lng\` for coordinates
|
|
26
|
+
|
|
27
|
+
### setCenter
|
|
28
|
+
Move the map center without adding markers.
|
|
29
|
+
\`\`\`
|
|
30
|
+
mapControl(action: "setCenter", location: "Shibuya, Tokyo")
|
|
31
|
+
\`\`\`
|
|
32
|
+
|
|
33
|
+
### setZoom
|
|
34
|
+
Change the zoom level (1-21).
|
|
35
|
+
- 1-5: Continent/Country level
|
|
36
|
+
- 6-10: Region/City level
|
|
37
|
+
- 11-15: Street level
|
|
38
|
+
- 16-21: Building level
|
|
39
|
+
\`\`\`
|
|
40
|
+
mapControl(action: "setZoom", zoom: 12)
|
|
41
|
+
\`\`\`
|
|
42
|
+
|
|
43
|
+
### addMarker
|
|
44
|
+
Add a marker at a location (without centering).
|
|
45
|
+
\`\`\`
|
|
46
|
+
mapControl(action: "addMarker", location: "Tokyo Tower", markerTitle: "Tokyo Tower", markerLabel: "T")
|
|
47
|
+
\`\`\`
|
|
48
|
+
|
|
49
|
+
### clearMarkers
|
|
50
|
+
Remove all markers from the map.
|
|
51
|
+
\`\`\`
|
|
52
|
+
mapControl(action: "clearMarkers")
|
|
53
|
+
\`\`\`
|
|
54
|
+
|
|
55
|
+
### findPlaces
|
|
56
|
+
Search for nearby places using Google Places API.
|
|
57
|
+
\`\`\`
|
|
58
|
+
mapControl(action: "findPlaces", searchQuery: "ramen")
|
|
59
|
+
mapControl(action: "findPlaces", placeType: "restaurant")
|
|
60
|
+
mapControl(action: "findPlaces", searchQuery: "coffee", placeType: "cafe")
|
|
61
|
+
\`\`\`
|
|
62
|
+
|
|
63
|
+
### getDirections
|
|
64
|
+
Get directions between two locations.
|
|
65
|
+
\`\`\`
|
|
66
|
+
mapControl(action: "getDirections", origin: "Tokyo Station", destination: "Tokyo Tower", travelMode: "WALKING")
|
|
67
|
+
\`\`\`
|
|
68
|
+
Travel modes: DRIVING, WALKING, BICYCLING, TRANSIT
|
|
69
|
+
|
|
70
|
+
## Response Data
|
|
71
|
+
|
|
72
|
+
The map will return JSON data with the results of each action, including:
|
|
73
|
+
- Current center coordinates and zoom level
|
|
74
|
+
- Markers on the map
|
|
75
|
+
- Place search results with ratings and addresses
|
|
76
|
+
- Route information with distance and duration`,f={toolDefinition:c,execute:n,generatingMessage:"Loading map...",isEnabled:o=>!!o?.googleMapKey,backends:["map"],systemPrompt:l},k=n,w=[{name:"Show Tokyo Station",args:{action:"showLocation",location:"Tokyo Station, Japan"}},{name:"Show Eiffel Tower",args:{action:"showLocation",location:"Eiffel Tower, Paris, France"}},{name:"Show coordinates",args:{action:"showLocation",lat:40.7128,lng:-74.006}},{name:"Center on Shibuya",args:{action:"setCenter",location:"Shibuya, Tokyo"}},{name:"Zoom to street level",args:{action:"setZoom",zoom:17}},{name:"Zoom to city level",args:{action:"setZoom",zoom:12}},{name:"Add marker at Tokyo Tower",args:{action:"addMarker",location:"Tokyo Tower, Japan",markerTitle:"Tokyo Tower",markerLabel:"T"}},{name:"Add marker with coordinates",args:{action:"addMarker",lat:35.6586,lng:139.7454,markerTitle:"Custom Location"}},{name:"Clear all markers",args:{action:"clearMarkers"}},{name:"Find nearby ramen",args:{action:"findPlaces",searchQuery:"ramen"}},{name:"Find restaurants",args:{action:"findPlaces",placeType:"restaurant"}},{name:"Find coffee shops",args:{action:"findPlaces",searchQuery:"coffee",placeType:"cafe"}},{name:"Directions: Tokyo Station to Shibuya",args:{action:"getDirections",origin:"Tokyo Station",destination:"Shibuya Station",travelMode:"TRANSIT"}},{name:"Walking directions",args:{action:"getDirections",origin:"Shinjuku Station",destination:"Tokyo Metropolitan Government Building",travelMode:"WALKING"}},{name:"Driving directions",args:{action:"getDirections",origin:"Narita Airport",destination:"Tokyo Station",travelMode:"DRIVING"}}];exports.TOOL_DEFINITION=c;exports.TOOL_NAME=s;exports.executeMap=k;exports.executeMapControl=n;exports.pluginCore=f;exports.samples=w;exports.systemPrompt=l;
|