├── .editorconfig
├── .eslintrc.js
├── .github
└── workflows
│ └── build.yml
├── .gitignore
├── .markdownlint.json
├── .prettierignore
├── .prettierrc
├── CHANGELOG.md
├── LICENSE
├── README.md
├── assets
└── docs cover art.afphoto
├── docs
├── .vitepress
│ ├── config.mts
│ ├── npm.svg
│ └── theme
│ │ ├── index.ts
│ │ └── style.css
├── advanced-usage
│ └── index.md
├── components
│ ├── advanced-marker.md
│ ├── circle.md
│ ├── custom-control.md
│ ├── custom-marker.md
│ ├── heatmap-layer.md
│ ├── index.md
│ ├── info-window.md
│ ├── marker-cluster.md
│ ├── marker.md
│ ├── polygon.md
│ ├── polyline.md
│ └── rectangle.md
├── getting-started
│ └── index.md
├── images
│ ├── map-1200.jpg
│ └── map-800.jpg
├── index.md
├── shared
│ └── index.ts
└── themes
│ └── index.md
├── netlify.toml
├── package.json
├── playground
├── App.vue
├── index.html
└── main.ts
├── pnpm-lock.yaml
├── scripts
└── build-umd.js
├── src
├── @types
│ └── index.ts
├── components
│ ├── AdvancedMarker.vue
│ ├── Circle.ts
│ ├── CustomControl.vue
│ ├── CustomMarker.vue
│ ├── GoogleMap.vue
│ ├── HeatmapLayer.ts
│ ├── InfoWindow.vue
│ ├── Marker.ts
│ ├── MarkerCluster.ts
│ ├── Polygon.ts
│ ├── Polyline.ts
│ ├── Rectangle.ts
│ └── index.ts
├── composables
│ ├── index.ts
│ └── useSetupMapComponent.ts
├── index.ts
├── shared
│ └── index.ts
├── shims-google-maps.ts
├── shims-vue.d.ts
├── themes
│ ├── aubergine.ts
│ ├── dark.ts
│ ├── grey.ts
│ ├── index.ts
│ ├── minimal.ts
│ ├── retro.ts
│ ├── roadways.ts
│ ├── roadwaysMinimal.ts
│ └── ultraLight.ts
└── utils
│ └── index.ts
├── tsconfig.build.json
├── tsconfig.json
├── tsconfig.node.json
└── vite.config.ts
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | charset = utf-8
5 | indent_style = space
6 | indent_size = 2
7 | end_of_line = lf
8 | insert_final_newline = true
9 | trim_trailing_whitespace = true
10 |
--------------------------------------------------------------------------------
/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | root: true,
3 | env: {
4 | node: true,
5 | },
6 | extends: [
7 | "plugin:vue/vue3-essential",
8 | "eslint:recommended",
9 | "@vue/typescript/recommended",
10 | "@vue/prettier",
11 | "@vue/prettier/@typescript-eslint",
12 | ],
13 | parserOptions: {
14 | ecmaVersion: 2020,
15 | },
16 | globals: {
17 | google: true,
18 | },
19 | rules: {
20 | "no-console": process.env.NODE_ENV === "production" ? "warn" : "off",
21 | "no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off",
22 | "@typescript-eslint/no-var-requires": "off",
23 | "brace-style": ["error", "1tbs", { allowSingleLine: true }],
24 | semi: ["error", "always"],
25 | quotes: ["warn", "double"],
26 | "@typescript-eslint/no-unused-vars": [
27 | "error",
28 | {
29 | varsIgnorePattern: "cases|^_",
30 | argsIgnorePattern: "^_",
31 | },
32 | ],
33 | },
34 | };
35 |
--------------------------------------------------------------------------------
/.github/workflows/build.yml:
--------------------------------------------------------------------------------
1 | name: Build & Publish
2 | on:
3 | push:
4 | branches:
5 | - main
6 |
7 | jobs:
8 | build:
9 | name: Main Job
10 | runs-on: ubuntu-latest
11 |
12 | steps:
13 | - name: Checkout 🛎
14 | uses: actions/checkout@v3
15 |
16 | - name: Setup Node ⚙️
17 | uses: actions/setup-node@v3
18 | with:
19 | node-version: 18.17.0
20 |
21 | - name: Install dependencies 👨🏻💻
22 | uses: pnpm/action-setup@v2
23 | with:
24 | version: 8
25 | run_install: |
26 | args: [--frozen-lockfile, --strict-peer-dependencies]
27 |
28 | - name: Build library 🛠
29 | run: pnpm build
30 |
31 | - name: Publish package 📦
32 | uses: JS-DevTools/npm-publish@v1
33 | with:
34 | token: ${{ secrets.NPM_TOKEN }}
35 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules
3 |
4 | # local env files
5 | .env
6 | .env.local
7 | .env.*.local
8 |
9 | # Log files
10 | npm-debug.log*
11 | yarn-debug.log*
12 | yarn-error.log*
13 |
14 | # Editor directories and files
15 | .idea
16 | *.suo
17 | *.ntvs*
18 | *.njsproj
19 | *.sln
20 | *.sw?
21 | .vscode
22 |
23 | # avoid having dist files in repo; these should only go to NPM
24 | dist
25 | docs/.vitepress/dist
26 | docs/.vitepress/cache
27 |
--------------------------------------------------------------------------------
/.markdownlint.json:
--------------------------------------------------------------------------------
1 | {
2 | "no-inline-html": false,
3 | "line-length": false,
4 | "no-duplicate-heading": false,
5 | "heading-increment": false
6 | }
7 |
--------------------------------------------------------------------------------
/.prettierignore:
--------------------------------------------------------------------------------
1 | docs
2 | README.md
3 |
--------------------------------------------------------------------------------
/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "printWidth": 120
3 | }
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 | All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4 |
5 | ### [0.22.0](https://github.com/inocan-group/vue3-google-maps/compare/v0.21.1...v0.22.0) (2025-04-28)
6 |
7 |
8 | ### Features
9 |
10 | * **AdvancedMarker:** support slot custom content ([c1fdb3f](https://github.com/inocan-group/vue3-google-maps/commit/c1fdb3f50234fd874a21be7d8d5f14dc0d5d0bfd))
11 | * colorScheme support ([29720fb](https://github.com/inocan-group/vue3-google-maps/commit/29720fbae3ebcd246e5614a5cd3a6972730ddb95)), closes [#289](https://github.com/inocan-group/vue3-google-maps/issues/289)
12 | * support cameraControl ([85b655e](https://github.com/inocan-group/vue3-google-maps/commit/85b655e1397e3e9cbb28115772e3fda3ab329100))
13 |
14 | ### [0.21.1](https://github.com/inocan-group/vue3-google-maps/compare/v0.21.0...v0.21.1) (2025-01-10)
15 |
16 | optimize CustomMarkerClass draw method ([93c2b50](https://github.com/inocan-group/vue3-google-maps/commit/93c2b50c1199e1236dc4ddc7b5b829595964b905))
17 |
18 |
19 | ### [0.21.0](https://github.com/inocan-group/vue3-google-maps/compare/v0.20.0...v0.21.0) (2024-08-04)
20 |
21 |
22 | ### Features
23 |
24 | * advanced markers ([69a1b66](https://github.com/inocan-group/vue3-google-maps/commit/69a1b666267e2ee840c0df7530b1fbcc810c7021))
25 |
26 |
27 | ### [0.20.0](https://github.com/inocan-group/vue3-google-maps/compare/v0.19.0...v0.20.0) (2024-03-19)
28 |
29 |
30 | ### Features
31 |
32 | * expose nonce option from @googlemaps/js-api-loader ([6e7bcdc](https://github.com/inocan-group/vue3-google-maps/commit/6e7bcdc87919b561cc34d89fb6b7b6e7fef07e6c))
33 |
34 |
35 | ### Bug Fixes
36 |
37 | * use with SSR ([5dd31c5](https://github.com/inocan-group/vue3-google-maps/commit/5dd31c5f9839259683c36cc6c43dcb8e37f8475c))
38 |
39 | ### [0.19.0](https://github.com/inocan-group/vue3-google-maps/compare/v0.18.0...v0.19.0) (2024-01-19)
40 |
41 |
42 | ### Features
43 |
44 | * add missing map props and events ([1e49172](https://github.com/inocan-group/vue3-google-maps/commit/1e491722b900925b827e1b572b644f51eb269fc3))
45 |
46 |
47 | ### Bug Fixes
48 |
49 | * v-show with custom controls ([6cec18c](https://github.com/inocan-group/vue3-google-maps/commit/6cec18c369fffc4b48b4ff7dcf77c32a024ff9d7))
50 |
51 | ### [0.18.0](https://github.com/inocan-group/vue3-google-maps/compare/v0.17.1...v0.18.0) (2023-09-28)
52 |
53 |
54 | ### Features
55 |
56 | * add v-model to infowindow ([64ac3ac](https://github.com/inocan-group/vue3-google-maps/commit/64ac3ac42a9125ccf538553e97ba5b8dd0ac2c66))
57 |
58 | ### [0.17.1](https://github.com/inocan-group/vue3-google-maps/compare/v0.17.0...v0.17.1) (2023-08-27)
59 |
60 |
61 | ### Bug Fixes
62 |
63 | * custom markers reactivity ([4a06b12](https://github.com/inocan-group/vue3-google-maps/commit/4a06b12b800fcb49d013c8b3cd5279f7ee0b5f25))
64 |
65 | ### [0.17.0](https://github.com/inocan-group/vue3-google-maps/compare/v0.16.0...v0.17.0) (2023-08-12)
66 |
67 |
68 | ### Features
69 |
70 | * **perf:** new default clustering algo ([#152](https://github.com/inocan-group/vue3-google-maps/issues/152)) ([3feb791](https://github.com/inocan-group/vue3-google-maps/commit/3feb791828f45066170e89aa94120a3cec36c447))
71 |
72 | ### [0.16.0](https://github.com/inocan-group/vue3-google-maps/compare/v0.15.0...v0.16.0) (2023-08-07)
73 |
74 |
75 | ### Features
76 |
77 | * expose open and close methods on InfoWindow ([d21dfba](https://github.com/inocan-group/vue3-google-maps/commit/d21dfbaea309c94d9c9ce8a8a58676cd1760b768))
78 | * info window enhancements ([57c895d](https://github.com/inocan-group/vue3-google-maps/commit/57c895d14104dfa48467fd5e46797db9f3723363))
79 |
80 |
81 | ### Bug Fixes
82 |
83 | * expose custom marker ([68f5a3e](https://github.com/inocan-group/vue3-google-maps/commit/68f5a3e2244e9a51abb3a7ccc3ebc394e3050b4b))
84 |
85 | ### [0.15.0](https://github.com/inocan-group/vue3-google-maps/compare/v0.14.1...v0.15.0) (2022-09-03)
86 |
87 | ### [0.14.1](https://github.com/inocan-group/vue3-google-maps/compare/v0.14.0...v0.14.1) (2022-08-31)
88 |
89 |
90 | ### Bug Fixes
91 |
92 | * heatmap layer ([ee04c85](https://github.com/inocan-group/vue3-google-maps/commit/ee04c85cc4491740d4d4593465b48eb7f618746b))
93 |
94 | ### [0.14.0](https://github.com/inocan-group/vue3-google-maps/compare/v0.13.2...v0.14.0) (2022-08-24)
95 |
96 |
97 | ### Features
98 |
99 | * heatmap layer ([d961636](https://github.com/inocan-group/vue3-google-maps/commit/d9616368e3aa263b45ad805058d73ae7e5c25ed2))
100 |
101 | ### [0.13.2](https://github.com/inocan-group/vue3-google-maps/compare/v0.13.1...v0.13.2) (2022-06-28)
102 |
103 |
104 | ### Bug Fixes
105 |
106 | * attrs fallthrough in custom markers and info windows ([c2a821f](https://github.com/inocan-group/vue3-google-maps/commit/c2a821feb1a27254a167eea717ac9f64fdd343a1))
107 |
108 | ### [0.13.1](https://github.com/inocan-group/vue3-google-maps/compare/v0.13.0...v0.13.1) (2022-06-27)
109 |
110 |
111 | ### Bug Fixes
112 |
113 | * dom management conflicts in custom markers ([f8f6bef](https://github.com/inocan-group/vue3-google-maps/commit/f8f6beff78a37499e981354dd51f81b1db1eaa6a))
114 | * dom management conflicts in info windows ([1d6e269](https://github.com/inocan-group/vue3-google-maps/commit/1d6e26938012b09e7f17a0276085a8935902dcc9))
115 |
116 | ## [0.13.0](https://github.com/inocan-group/vue3-google-maps/compare/v0.12.0...v0.13.0) (2022-05-28)
117 |
118 |
119 | ### Features
120 |
121 | * allow loading api script externally ([2a55b60](https://github.com/inocan-group/vue3-google-maps/commit/2a55b60ae57fedf0e5315cb696bbbf9f70a1c2ae))
122 |
123 | ## [0.12.0](https://github.com/inocan-group/vue3-google-maps/compare/v0.10.0...v0.12.0) (2022-05-19)
124 |
125 |
126 | ### Features
127 |
128 | * custom markers ([ecc28b0](https://github.com/inocan-group/vue3-google-maps/commit/ecc28b0455a54502734ae1ae9b1d69cde9e0652e))
129 | * add mapId in GoogleMap Component ([b72105c](https://github.com/inocan-group/vue3-google-maps/commit/b72105ca33bcf115ce83fe5a09ad4ccc5530d8bc))
130 | ## [0.11.0](https://github.com/inocan-group/vue3-google-maps/compare/v0.10.0...v0.11.0) (2022-05-11)
131 |
132 |
133 | ### Features
134 |
135 | * marker clusters ([5d58e2e](https://github.com/inocan-group/vue3-google-maps/commit/5d58e2e9ead8356c972d7700b9218ba77889ad15))
136 |
137 | ## [0.10.0](https://github.com/inocan-group/vue3-google-maps/compare/v0.9.0...v0.10.0) (2022-03-25)
138 |
139 |
140 | ### ⚠ BREAKING CHANGES
141 |
142 | * separate entry point for bundled themes
143 |
144 | ### build
145 |
146 | * separate entry point for bundled themes ([27ff148](https://github.com/inocan-group/vue3-google-maps/commit/27ff148714656d04415d84b2c11663e4b0c84e16))
147 |
148 | ## [0.9.0](https://github.com/inocan-group/vue3-google-maps/compare/v0.8.5...v0.9.0) (2022-03-22)
149 |
150 |
151 | ### Features
152 |
153 | * ability to nest info windows inside markers ([c239cc7](https://github.com/inocan-group/vue3-google-maps/commit/c239cc7ad0851ec0238e178e10835a9dfb0169a9))
154 |
155 | ### [0.8.5](https://github.com/inocan-group/vue3-google-maps/compare/v0.8.4...v0.8.5) (2022-03-21)
156 |
157 |
158 | ### Bug Fixes
159 |
160 | * unwrap component refs ([8d0443b](https://github.com/inocan-group/vue3-google-maps/commit/8d0443befd842dd40169a0bda70fe5a8380ebeca))
161 |
162 | ### [0.8.4](https://github.com/inocan-group/vue3-google-maps/compare/v0.8.3...v0.8.4) (2022-03-20)
163 |
164 |
165 | ### Features
166 |
167 | * info windows ([6a294f2](https://github.com/inocan-group/vue3-google-maps/commit/6a294f2a86b55dca96137bde5e719923c634c4a7))
168 |
169 | ### [0.8.3](https://github.com/inocan-group/vue3-google-maps/compare/v0.8.2...v0.8.3) (2021-12-12)
170 |
171 |
172 | ### Bug Fixes
173 |
174 | * make js-api-loader a dependency ([a8fb747](https://github.com/inocan-group/vue3-google-maps/commit/a8fb747ebd290e87a1572a2c8fcf6efd64b6f282))
175 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2020-present, Inocan Group
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # vue3-google-map
2 |
3 | 
4 | [](https://github.com/inocan-group/vue3-google-map/blob/develop/LICENSE)
5 |
6 | > Composable components for easy use of Google Maps with Vue 3
7 |
8 | `vue3-google-map` offers a set of composable components for easy use of Google Maps in your Vue 3 projects.
9 |
10 | Note: Please refer to the [documentation site](https://vue3-google-map.com/) for rendered examples.
11 |
12 | ## Table of Contents
13 |
14 | - [Getting Started](#getting-started)
15 | - [Installation](#installation)
16 | - [Your First Map](#your-first-map)
17 | - [Components](#components)
18 | - [Advanced Marker](#advanced-marker)
19 | - [Marker](#marker)
20 | - [Polyline](#polyline)
21 | - [Polygon](#polygon)
22 | - [Rectangle](#rectangle)
23 | - [Circle](#circle)
24 | - [Info Window](#info-window)
25 | - [Custom Marker](#custom-marker)
26 | - [Custom Control](#custom-control)
27 | - [Marker Cluster](#marker-cluster)
28 | - [Heatmap Layer](#heatmap-layer)
29 | - [Advanced Usage](#advanced-usage)
30 | - [Contribution](#contribution)
31 | - [License](#license)
32 |
33 | ## Getting Started
34 |
35 | ### Installation
36 |
37 | #### NPM
38 |
39 | ```bash
40 | npm install vue3-google-map
41 | # OR
42 | pnpm add vue3-google-map
43 | ```
44 |
45 | #### CDN
46 |
47 | Include the following script tag in your `index.html` (make sure to include it after Vue 3's global build).
48 |
49 | ```html
50 |
51 | ```
52 |
53 | All the map components are available on the `Vue3GoogleMap` global variable.
54 |
55 | [Codepen demo](https://codepen.io/husamibrahim/pen/poQXZbR)
56 |
57 | ### Your First Map
58 |
59 | To construct a map using `vue3-google-map` you'll need to use the base `GoogleMap` component which receives your [Google Maps API key](https://developers.google.com/maps/documentation/javascript/get-api-key), styles (e.g. setting width and height), and any [MapOptions](https://developers.google.com/maps/documentation/javascript/reference/map#MapOptions) to configure your map ([see this](https://github.com/inocan-group/vue3-google-map/blob/develop/src/components/GoogleMap.vue#L36-L244) for all the supported `MapOptions`).
60 | Other map features can be added to your map by passing map subcomponents ([Marker](#marker), [Polyline](#polyline), [Polygon](#polygon), [Rectangle](#rectangle), [Circle](#circle), [InfoWindow](#info-window), [CustomMarker](#custom-marker), [CustomControl](#custom-control), or [MarkerCluster](#marker-cluster)) to the default slot of the `GoogleMap` component.
61 |
62 | The [the following events](https://developers.google.com/maps/documentation/javascript/reference/map#Map-Events) will be emitted by the `GoogleMap` component and can be listened to by using `@event_name`.
63 |
64 | ```vue
65 |
70 |
71 |
72 |
78 |
79 |
80 |
81 | ```
82 |
83 | ## Components
84 |
85 | This library is intended to be used in a composable fashion. Therefore you will find yourself using nested components to build your map rather than just a complicated inline format.
86 |
87 | The main mapping component is `GoogleMap`, however the following components are available at your disposal:
88 |
89 | - [AdvancedMarker](#advanced-marker)
90 | - [Marker](#marker)
91 | - [Polyline](#polyline)
92 | - [Polygon](#polygon)
93 | - [Rectangle](#rectangle)
94 | - [Circle](#circle)
95 | - [InfoWindow](#info-window)
96 | - [CustomMarker](#custom-marker)
97 | - [CustomControl](#custom-control)
98 | - [MarkerCluster](#marker-cluster)
99 |
100 | ### Advanced Marker
101 |
102 | Use the `AdvancedMarker` component to draw markers, drop pins or any custom icons on a map. `AdvancedMarker` is the new version offered by google when deprecated the `Marker` component ([read more here](https://developers.google.com/maps/deprecations#googlemapsmarker_in_the_deprecated_as_of_february_2024)).
103 |
104 | In order to use the `AdvancedMarker` component is necessary to specify a MapId on declaring the `GoogleMap` component ([see more here](https://developers.google.com/maps/documentation/javascript/advanced-markers/start#create_a_map_id)).
105 |
106 | #### Options
107 |
108 | You can pass a [AdvancedMarkerElementOptions](https://developers.google.com/maps/documentation/javascript/reference/advanced-markers#AdvancedMarkerElementOptions) object to the `options` prop to configure your marker.
109 |
110 | You can also pass a [PinElementOptions interface](https://developers.google.com/maps/documentation/javascript/reference/advanced-markers#PinElementOptions) object to customize pin used by the marker.
111 |
112 | Additionally, `AdvancedMarker` supports default slot content, allowing you to use custom HTML or Vue components inside the marker.
113 |
114 | ```vue
115 |
122 |
123 |
124 |
131 |
132 |
133 |
134 | Custom Content
135 |
136 |
137 |
138 |
139 | ```
140 |
141 | #### Events
142 |
143 | You can listen for [the following events](https://developers.google.com/maps/documentation/javascript/reference/advanced-markers#AdvancedMarkerElement-Events) on the `AdvancedMarker` component.
144 |
145 | ### Marker
146 |
147 | Use the `Marker` component to draw markers, drop pins or any custom icons on a map.
148 |
149 | #### Options
150 |
151 | You can pass a [MarkerOptions](https://developers.google.com/maps/documentation/javascript/reference/marker#MarkerOptions) object to the `options` prop to configure your marker.
152 |
153 | ```vue
154 |
160 |
161 |
162 |
168 |
169 |
170 |
171 | ```
172 |
173 | #### Events
174 |
175 | You can listen for [the following events](https://developers.google.com/maps/documentation/javascript/reference/marker#Marker-Events) on the `Marker` component.
176 |
177 | ### Polyline
178 |
179 | Use the `Polyline` component to draw paths and arbitrary shapes on a map.
180 |
181 | #### Options
182 |
183 | You can pass a [PolylineOptions](https://developers.google.com/maps/documentation/javascript/reference/polygon#PolylineOptions) object to the `options` prop to configure your polyline.
184 |
185 | ```vue
186 |
204 |
205 |
206 |
212 |
213 |
214 |
215 | ```
216 |
217 | #### Events
218 |
219 | You can listen for [the following events](https://developers.google.com/maps/documentation/javascript/reference/polygon#Polyline-Events) on the `Polyline` component.
220 |
221 | ### Polygon
222 |
223 | Use the `Polygon` component to draw polgons (arbitrary number of sides) on a map.
224 |
225 | #### Options
226 |
227 | You can pass a [PolylgonOptions](https://developers.google.com/maps/documentation/javascript/reference/polygon#PolygonOptions) object to the `options` prop to configure your polyline.
228 |
229 | ```vue
230 |
249 |
250 |
251 |
257 |
258 |
259 |
260 | ```
261 |
262 | #### Events
263 |
264 | You can listen for [the following events](https://developers.google.com/maps/documentation/javascript/reference/polygon#Polygon-Events) on the `Polygon` component.
265 |
266 | ### Rectangle
267 |
268 | Use the `Rectangle` component to draw simple rectangles on a map.
269 |
270 | #### Options
271 |
272 | You can pass a [RectangleOptions](https://developers.google.com/maps/documentation/javascript/reference/polygon#RectangleOptions) object to the `options` prop to configure your rectangle.
273 |
274 | ```vue
275 |
293 |
294 |
295 |
302 |
303 |
304 |
305 | ```
306 |
307 | #### Events
308 |
309 | You can listen for [the following events](https://developers.google.com/maps/documentation/javascript/reference/polygon#Rectangle-Events) on the `Rectangle` component.
310 |
311 | ### Circle
312 |
313 | Use the `Circle` component to draw circles on a map.
314 |
315 | #### Options
316 |
317 | You can pass a [CircleOptions](https://developers.google.com/maps/documentation/javascript/reference/polygon#CircleOptions) object to the `options` prop to configure your circle.
318 |
319 | ```vue
320 |
357 |
358 |
359 |
366 |
367 |
368 |
369 | ```
370 |
371 | #### Events
372 |
373 | You can listen for [the following events](https://developers.google.com/maps/documentation/javascript/reference/polygon#Circle-Events) on the `Circle` component.
374 |
375 | ### Info Window
376 |
377 | Use the `InfoWindow` component to display content in a popup window above the map, at a given location.
378 |
379 | #### Options
380 |
381 | You can pass an [InfoWindowOptions](https://developers.google.com/maps/documentation/javascript/reference#InfoWindowOptions) object to the `options` prop to configure your info window. Note that you can optionally pass your content to the default slot of the `InfoWindow` component.
382 |
383 | ```vue
384 |
389 |
390 |
391 |
397 |
398 |
399 | Content passed through slot
400 |
401 |
402 |
403 | ```
404 |
405 | #### Use with Marker
406 |
407 | You can nest the `InfoWindow` component inside the `Marker` component to display an info window when the marker is clicked.
408 |
409 | ```vue
410 |
415 |
416 |
417 |
423 |
424 |
425 |
426 |
427 |
Uluru
428 |
429 |
Uluru, also referred to as Ayers Rock, is a large
430 | sandstone rock formation in the southern part of the
431 | Northern Territory, central Australia. It lies 335 km (208 mi)
432 | south west of the nearest large town, Alice Springs; 450 km
433 | (280 mi) by road. Kata Tjuta and Uluru are the two major
434 | features of the Uluru - Kata Tjuta National Park. Uluru is
435 | sacred to the Pitjantjatjara and Yankunytjatjara, the
436 | Aboriginal people of the area. It has many springs, waterholes,
437 | rock caves and ancient paintings. Uluru is listed as a World
438 | Heritage Site.
444 |
445 |
446 |
447 |
448 | ```
449 |
450 | #### Open and close the Info Window
451 |
452 | You can use `v-model` to manage the state of the info window programmatically or to know whether it's open or closed
453 |
454 | ```vue
455 |
466 |
467 |
468 |
474 |
475 |
476 |
This is the infowindow content
477 |
478 |
479 |
480 |
481 | ```
482 |
483 | #### Events
484 |
485 | You can listen for [the following events](https://developers.google.com/maps/documentation/javascript/reference/info-window#InfoWindow-Events) on the `InfoWindow` component.
486 |
487 | ### Custom Marker
488 |
489 | Regular markers can be customized a great deal but if you need to you can use the `CustomMarker` component and provide your own custom markup through it's `default` slot.
490 |
491 | #### Options
492 |
493 | | Parameter | Type | Description |
494 | | :-------- | :------- | :------------------------- |
495 | | `position` | `{ lat: number, lng: number}` | Sets the marker position. |
496 | | `anchorPoint` | `'CENTER' \| 'TOP_CENTER' \|'BOTTOM_CENTER' \| 'LEFT_CENTER' \| 'RIGHT_CENTER' \| 'TOP_LEFT' \| 'TOP_RIGHT' \| 'BOTTOM_LEFT' \| 'BOTTOM_RIGHT'` | Sets how the marker is anchored relative to it's `position` point. Default is `CENTER`. |
497 | | `offsetX` | `number` | Horizontal offset from the `position` point. |
498 | | `offsetY` | `number` | Vertical offset from the `position` point. |
499 | | `zIndex` | `number` | `z-index` value of the marker. |
500 |
501 | ```vue
502 |
507 |
508 |
509 |
515 |
516 |
517 |
Vuejs Amsterdam
518 |
519 |
520 |
521 |
522 |
523 | ```
524 |
525 | ### Custom Control
526 |
527 | Use the `CustomControl` component to add custom buttons/controls to your map.
528 |
529 | #### Usage
530 |
531 | You can define the markup of your custom control in the `default` slot of the `CustomControl` component. The component itself takes two props:
532 |
533 | - `position`: Defines the position of your custom control on the map. Its value must be one of the [ControlPosition](https://developers.google.com/maps/documentation/javascript/reference/control#ControlPosition) constants.
534 | - `index` (optional): Controls the order of placement for custom controls that occupy the same position.
535 |
536 | Refer to the [Google Maps documentation](https://developers.google.com/maps/documentation/javascript/controls#CustomControls) on custom controls positioning.
537 |
538 | ```vue
539 |
545 |
546 |
547 |
553 |
554 |
555 |
556 |
557 |
558 |
559 |
578 | ```
579 |
580 | ### Marker Cluster
581 |
582 | Use the `MarkerCluster` component to display a large number of markers on a map. It will combine markers of close proximity into clusters, and simplify the display of markers on the map. Can be used with the `Marker` or `CustomMarker` components.
583 |
584 | #### Usage
585 |
586 | Simply pass your `Marker`/`CustomMarker`(s) in the `default` slot of the `MarkerCluster` component.
587 |
588 | ```vue
589 |
620 |
621 |
622 |
628 |
629 |
634 |
635 |
636 |
637 | ```
638 |
639 | #### Options
640 |
641 | `MarkerCluster` accepts an `options` prop (an object) where you can configure `algorithm`, `onClusterClick`, and `renderer` from the [MarkerClustererOptions](https://googlemaps.github.io/js-markerclusterer/interfaces/MarkerClustererOptions.html) interface. Note that all these options are completely optional but non-reactive.
642 |
643 | #### Events
644 |
645 | You can listen for [the following events](https://googlemaps.github.io/js-markerclusterer/enums/MarkerClustererEvents.html) on the `MarkerCluster` component.
646 |
647 | ### Heatmap Layer
648 |
649 | Use the `HeatmapLayer` component to depict the intensity of data at geographical points on the map. Make sure to include the `visualization` library in the `libraries` prop of the `GoogleMap` component.
650 |
651 | #### Options
652 |
653 | You can pass a [HeatmapLayerOptions](https://developers.google.com/maps/documentation/javascript/reference/visualization#HeatmapLayerOptions) object to the `options` prop to configure your heatmap layer. Note that for convenience you can use [LatLngLiteral](https://developers.google.com/maps/documentation/javascript/reference/coordinates#LatLngLiteral)s if you wish for the locations.
654 |
655 | ```vue
656 |
679 |
680 |
681 |
688 |
689 |
690 |
691 | ```
692 |
693 | ## Advanced Usage
694 |
695 | The basic components that `vue3-google-map` provides are fully reactive and will get you pretty far. Should you need to access the Google Maps API, however, the `GoogleMap` component exposes the following:
696 |
697 | - `ready`: A boolean indicating when the Google Maps script has been loaded. By this point the map instance has been created, the API is ready for use and event listeners have been set up on the map.
698 | - `map`: The [Map](https://developers.google.com/maps/documentation/javascript/reference/map#Map) class instance.
699 | - `api`: The [Google Maps API](https://developers.google.com/maps/documentation/javascript/reference).
700 | - `mapTilesLoaded`: A boolean indicating when the map tiles have been fully loaded.
701 |
702 | In addition, most of the subcomponents expose their instance should you need it:
703 |
704 | - `Marker` exposes `marker` (a [Marker](https://developers.google.com/maps/documentation/javascript/reference/marker#Marker) class instance).
705 | - `Polyline` exposes `polyline` (a [Polyline](https://developers.google.com/maps/documentation/javascript/reference/polygon#Polyline) class instance).
706 | - `Polygon` exposes `polygon` (a [Polygon](https://developers.google.com/maps/documentation/javascript/reference/polygon#Polygon) class instance).
707 | - `Rectangle` exposes `rectangle` (a [Rectangle](https://developers.google.com/maps/documentation/javascript/reference/polygon#Rectangle) class instance).
708 | - `Circle` exposes `circle` (a [Circle](https://developers.google.com/maps/documentation/javascript/reference/polygon#Circle) class instance).
709 | - `InfoWindow` exposes `infoWindow` (an [InfoWindow](https://developers.google.com/maps/documentation/javascript/reference/info-window#InfoWindow) class instance).
710 | - `MarkerCluster` exposes `markerCluster` (a [MarkerClusterer](https://googlemaps.github.io/js-markerclusterer/classes/MarkerClusterer.html) class instance).
711 | - `HeatmapLayer` exposes `heatmapLayer` (a [HeatmapLayer](https://developers.google.com/maps/documentation/javascript/reference/visualization#HeatmapLayer) class instance).
712 |
713 | ### Usage Patterns
714 |
715 | ```vue
716 |
738 |
739 |
740 |
741 |
742 |
745 |
746 |
747 |
748 | ```
749 |
750 | Example:
751 |
752 | ```vue
753 |
783 |
784 |
785 |
792 |
793 |
794 |
795 |
796 |
824 | ```
825 |
826 | ### Loading the Google Maps API script externally
827 |
828 | By default you would pass your API key as a prop to the `GoogleMap` component and it handles the loading of the Google Maps API script for you. There are cases, however, where you might want to load the script yourself. For example, you might be using other Google Maps components or your Vue app might be a part of a larger app that uses the Google Maps API elsewhere. In these cases you can use the `apiPromise` prop to pass a promise that resolves to the Google Maps API global `google` object.
829 |
830 | ```vue
831 |
845 |
846 |
847 |
853 |
854 |
855 |
856 | ```
857 |
858 | ## Contribution
859 |
860 | All contributions are welcome. Before submitting a PR though it would be nice if you created an issue explaining what you want to acheive and why.
861 |
862 | ## License
863 |
864 | [MIT](http://opensource.org/licenses/MIT)
865 |
--------------------------------------------------------------------------------
/assets/docs cover art.afphoto:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inocan-group/vue3-google-map/34c2cc4bde5eca3efc8ecc8562d484b68d346307/assets/docs cover art.afphoto
--------------------------------------------------------------------------------
/docs/.vitepress/config.mts:
--------------------------------------------------------------------------------
1 | import { fileURLToPath } from "node:url";
2 | import { defineConfig } from 'vitepress'
3 |
4 | export default defineConfig({
5 | title: "vue3-google-map",
6 | description: "vue3-google-map documentation",
7 | themeConfig: {
8 | search: {
9 | provider: 'local'
10 | },
11 |
12 | sidebar: [
13 | {
14 | text: "Getting Started",
15 | link: "/getting-started/",
16 | },
17 | {
18 | text: "Components",
19 | link: "/components/",
20 | collapsed: false,
21 | items: [
22 | {
23 | text: "Advanced Marker",
24 | link: "/components/advanced-marker",
25 | },
26 | {
27 | text: "Marker",
28 | link: "/components/marker",
29 | },
30 | {
31 | text: "Polyline",
32 | link: "/components/polyline",
33 | },
34 | {
35 | text: "Polygon",
36 | link: "/components/polygon",
37 | },
38 | {
39 | text: "Rectangle",
40 | link: "/components/rectangle",
41 | },
42 | {
43 | text: "Circle",
44 | link: "/components/circle",
45 | },
46 | {
47 | text: "Info Window",
48 | link: "/components/info-window",
49 | },
50 | {
51 | text: "Custom Marker",
52 | link: "/components/custom-marker",
53 | },
54 | {
55 | text: "Custom Control",
56 | link: "/components/custom-control",
57 | },
58 | {
59 | text: "Marker Cluster",
60 | link: "/components/marker-cluster",
61 | },
62 | {
63 | text: "Heatmap Layer",
64 | link: "/components/heatmap-layer",
65 | },
66 | ],
67 | },
68 | {
69 | text: "Advanced Usage",
70 | link: "/advanced-usage/",
71 | },
72 | ],
73 |
74 | socialLinks: [
75 | {
76 | icon: {
77 | svg:'',
78 | },
79 | link: 'https://www.npmjs.com/package/vue3-google-map',
80 | ariaLabel: 'npm',
81 | },
82 | { icon: 'github', link: 'https://github.com/inocan-group/vue3-google-map' },
83 | ]
84 | },
85 |
86 | vite: {
87 | ssr: {
88 | noExternal: [
89 | '@googlemaps/js-api-loader',
90 | '@googlemaps/markerclusterer',
91 | ]
92 | },
93 | resolve: {
94 | alias: {
95 | "@lib": fileURLToPath(new URL("../../src/index.ts", import.meta.url)),
96 | "@docs": fileURLToPath(new URL("..", import.meta.url)),
97 | },
98 | }
99 | }
100 | });
101 |
--------------------------------------------------------------------------------
/docs/.vitepress/npm.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/docs/.vitepress/theme/index.ts:
--------------------------------------------------------------------------------
1 | // https://vitepress.dev/guide/custom-theme
2 | import { h } from 'vue'
3 | import type { Theme } from 'vitepress'
4 | import DefaultTheme from 'vitepress/theme'
5 | import './style.css'
6 |
7 | export default {
8 | extends: DefaultTheme,
9 | Layout: () => {
10 | return h(DefaultTheme.Layout, null, {
11 | // https://vitepress.dev/guide/extending-default-theme#layout-slots
12 | })
13 | },
14 | enhanceApp({ app, router, siteData }) {
15 | // ...
16 | }
17 | } satisfies Theme
18 |
--------------------------------------------------------------------------------
/docs/.vitepress/theme/style.css:
--------------------------------------------------------------------------------
1 | :root {
2 | --vp-c-brand-1: var(--vp-c-green-1);
3 | --vp-c-brand-2: var(--vp-c-green-2);
4 | --vp-c-brand-3: var(--vp-c-green-3);
5 | --vp-c-brand-soft: var(--vp-c-green-soft);
6 | --vp-code-color: #476582;
7 | }
8 |
9 | :root.dark {
10 | --vp-code-color: #c9def1;
11 |
12 | --vp-home-hero-image-filter: blur(72px);
13 | --vp-home-hero-image-background-image: linear-gradient(
14 | 0deg,
15 | var(--vp-c-brand-soft) 50%,
16 | var(--vp-c-brand-soft) 50%
17 | );
18 | }
19 |
--------------------------------------------------------------------------------
/docs/advanced-usage/index.md:
--------------------------------------------------------------------------------
1 |
32 |
33 | # Advanced Usage
34 |
35 | The basic components that `vue3-google-map` provides are fully reactive and will get you pretty far. Should you need to access the Google Maps API, however, the `GoogleMap` component exposes the following:
36 |
37 | - `ready`: A boolean indicating when the Google Maps script has been loaded. By this point the map instance has been created, the API is ready for use and event listeners have been set up on the map.
38 | - `map`: The [Map](https://developers.google.com/maps/documentation/javascript/reference/map#Map) class instance.
39 | - `api`: The [Google Maps API](https://developers.google.com/maps/documentation/javascript/reference).
40 | - `mapTilesLoaded`: A boolean indicating when the map tiles have been fully loaded.
41 |
42 | In addition, most of the subcomponents expose their instance should you need it:
43 |
44 | - `Marker` exposes `marker` (a [Marker](https://developers.google.com/maps/documentation/javascript/reference/marker#Marker) class instance).
45 | - `Polyline` exposes `polyline` (a [Polyline](https://developers.google.com/maps/documentation/javascript/reference/polygon#Polyline) class instance).
46 | - `Polygon` exposes `polygon` (a [Polygon](https://developers.google.com/maps/documentation/javascript/reference/polygon#Polygon) class instance).
47 | - `Rectangle` exposes `rectangle` (a [Rectangle](https://developers.google.com/maps/documentation/javascript/reference/polygon#Rectangle) class instance).
48 | - `Circle` exposes `circle` (a [Circle](https://developers.google.com/maps/documentation/javascript/reference/polygon#Circle) class instance).
49 | - `InfoWindow` exposes `infoWindow` (an [InfoWindow](https://developers.google.com/maps/documentation/javascript/reference/info-window#InfoWindow) class instance).
50 | - `MarkerCluster` exposes `markerCluster` (a [MarkerClusterer](https://googlemaps.github.io/js-markerclusterer/classes/MarkerClusterer.html) class instance).
51 | - `HeatmapLayer` exposes `heatmapLayer` (a [HeatmapLayer](https://developers.google.com/maps/documentation/javascript/reference/visualization#HeatmapLayer) class instance).
52 |
53 | ## Usage Patterns
54 |
55 | ```vue
56 |
78 |
79 |
80 |
81 |
82 |
85 |
86 |
87 |
88 | ```
89 |
90 | Example:
91 |
92 | ```vue
93 |
123 |
124 |
125 |
132 |
133 |
134 |
135 |
136 |
164 | ```
165 |
166 |
167 |
174 |
175 |
176 |
177 |
178 | ## Loading the Google Maps API script externally
179 |
180 | By default you would pass your API key as a prop to the `GoogleMap` component and it handles the loading of the Google Maps API script for you. There are cases, however, where you might want to load the script yourself. For example, you might be using other Google Maps components or your Vue app might be a part of a larger app that uses the Google Maps API elsewhere. In these cases you can use the `apiPromise` prop to pass a promise that resolves to the Google Maps API global `google` object.
181 |
182 | ```vue
183 |
197 |
198 |
199 |
205 |
206 |
207 |
208 | ```
209 |
210 | ## Events
211 |
212 | You can listen for [the following events](https://developers.google.com/maps/documentation/javascript/reference/map#Map-Events) on the `GoogleMap` component by using `@event_name`. For example if you want to call a function whenever the zoom value is changed, you can use it like this:
213 |
214 | ```vue
215 |
218 | ```
219 |
220 |
221 |
249 |
--------------------------------------------------------------------------------
/docs/components/advanced-marker.md:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 | # Advanced Marker
10 |
11 | Use the `AdvancedMarker` component to draw markers, drop pins or any custom icons on a map. `AdvancedMarker` is the new version offered by google when deprecated the `Marker` component ([read more here](https://developers.google.com/maps/deprecations#googlemapsmarker_in_the_deprecated_as_of_february_2024)).
12 |
13 | In order to use the `AdvancedMarker` component is necessary to specify a MapId on declaring the `GoogleMap` component ([see more here](https://developers.google.com/maps/documentation/javascript/advanced-markers/start#create_a_map_id)).
14 |
15 | ## Options
16 |
17 | You can pass a [AdvancedMarkerElementOptions](https://developers.google.com/maps/documentation/javascript/reference/advanced-markers#AdvancedMarkerElementOptions) object to the `options` prop to configure your marker.
18 |
19 | You can also pass a [PinElementOptions interface](https://developers.google.com/maps/documentation/javascript/reference/advanced-markers#PinElementOptions) object to customize pin used by the marker.
20 |
21 | Additionally, `AdvancedMarker` supports default slot content, allowing you to use custom HTML or Vue components inside the marker.
22 |
23 | ```vue
24 |
31 |
32 |
33 |
40 |
41 |
42 |
63 |
64 |
65 |
66 |
67 | ## Events
68 |
69 | You can listen for [the following events](https://developers.google.com/maps/documentation/javascript/reference/advanced-markers#AdvancedMarkerElement-Events) on the `AdvancedMarker` component.
70 |
--------------------------------------------------------------------------------
/docs/components/circle.md:
--------------------------------------------------------------------------------
1 |
39 |
40 | # Circle
41 |
42 | Use the `Circle` component to draw circles on a map.
43 |
44 | ## Options
45 |
46 | You can pass a [CircleOptions](https://developers.google.com/maps/documentation/javascript/reference/polygon#CircleOptions) object to the `options` prop to configure your circle.
47 |
48 | ```vue
49 |
86 |
87 |
88 |
95 |
96 |
97 |
98 | ```
99 |
100 |
101 |
108 |
109 |
110 |
111 |
112 | ## Events
113 |
114 | You can listen for [the following events](https://developers.google.com/maps/documentation/javascript/reference/polygon#Circle-Events) on the `Circle` component.
115 |
--------------------------------------------------------------------------------
/docs/components/custom-control.md:
--------------------------------------------------------------------------------
1 | ---
2 | outline: false
3 | ---
4 |
5 |
12 |
13 | # Custom Control
14 |
15 | Use the `CustomControl` component to add custom buttons/controls to your map.
16 |
17 | ## Usage
18 |
19 | You can define the markup of your custom control in the `default` slot of the `CustomControl` component. The component itself takes two props:
20 |
21 | - `position`: Defines the position of your custom control on the map. Its value must be one of the [ControlPosition](https://developers.google.com/maps/documentation/javascript/reference/control#ControlPosition) constants.
22 | - `index` (optional): Controls the order of placement for custom controls that occupy the same position.
23 |
24 | Refer to the [Google Maps documentation](https://developers.google.com/maps/documentation/javascript/controls#CustomControls) on custom controls positioning.
25 |
26 | ```vue
27 |
33 |
34 |
35 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
66 | ```
67 |
68 |
69 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
100 |
--------------------------------------------------------------------------------
/docs/components/custom-marker.md:
--------------------------------------------------------------------------------
1 | ---
2 | outline: false
3 | ---
4 |
5 |
11 |
12 | # Custom Marker
13 |
14 | Regular markers can be customized a great deal but if you need to you can use the `CustomMarker` component and provide your own custom markup through it's `default` slot.
15 |
16 | ## Options
17 |
18 | | Parameter | Type | Description |
19 | | :-------- | :------- | :------------------------- |
20 | | `position` | `{ lat: number, lng: number}` | Sets the marker position. |
21 | | `anchorPoint` | `'CENTER' \| 'TOP_CENTER' \|'BOTTOM_CENTER' \| 'LEFT_CENTER' \| 'RIGHT_CENTER' \| 'TOP_LEFT' \| 'TOP_RIGHT' \| 'BOTTOM_LEFT' \| 'BOTTOM_RIGHT'` | Sets how the marker is anchored relative to it's `position` point. Default is `CENTER`. |
22 | | `offsetX` | `number` | Horizontal offset from the `position` point. |
23 | | `offsetY` | `number` | Vertical offset from the `position` point. |
24 | | `zIndex` | `number` | `z-index` value of the marker. |
25 |
26 | ```vue
27 |
32 |
33 |
34 |
40 |
41 |
42 |
Vuejs Amsterdam
43 |
44 |
45 |
46 |
47 |
48 | ```
49 |
50 |
51 |
57 |
58 |
59 |
Vuejs Amsterdam
60 |
61 |
62 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/docs/components/heatmap-layer.md:
--------------------------------------------------------------------------------
1 |
25 |
26 | # Heatmap Layer
27 |
28 | Use the `HeatmapLayer` component to depict the intensity of data at geographical points on the map. Make sure to include the `visualization` library in the `libraries` prop of the `GoogleMap` component.
29 |
30 | ## Options
31 |
32 | You can pass a [HeatmapLayerOptions](https://developers.google.com/maps/documentation/javascript/reference/visualization#HeatmapLayerOptions) object to the `options` prop to configure your heatmap layer. Note that for convenience you can use [LatLngLiteral](https://developers.google.com/maps/documentation/javascript/reference/coordinates#LatLngLiteral)s if you wish for the locations.
33 |
34 | ```vue
35 |
58 |
59 |
60 |
67 |
68 |
69 |
70 | ```
71 |
72 |
73 |
79 |
80 |
81 |
82 |
--------------------------------------------------------------------------------
/docs/components/index.md:
--------------------------------------------------------------------------------
1 | # Components
2 |
3 | This library is intended to be used in a composable fashion. Therefore you will find yourself using nested components to build your map rather than just a complicated inline format.
4 |
5 | The main mapping component is `GoogleMap`, however the following components are available at your disposal:
6 |
7 | - [AdvancedMarker](./advanced-marker.md)
8 | - [Marker](./marker.md)
9 | - [Polyline](./polyline.md)
10 | - [Polygon](./polygon.md)
11 | - [Rectangle](./rectangle.md)
12 | - [Circle](./circle.md)
13 | - [Info Window](./info-window.md)
14 | - [Custom Marker](./custom-marker.md)
15 | - [Custom Control](./custom-control.md)
16 | - [Marker Cluster](./marker-cluster.md)
17 | - [Heatmap Layer](./heatmap-layer.md)
18 |
--------------------------------------------------------------------------------
/docs/components/info-window.md:
--------------------------------------------------------------------------------
1 |
5 |
6 | # Info Window
7 |
8 | Use the `InfoWindow` component to display content in a popup window above the map, at a given location.
9 |
10 | ## Options
11 |
12 | You can pass an [InfoWindowOptions](https://developers.google.com/maps/documentation/javascript/reference#InfoWindowOptions) object to the `options` prop to configure your info window. Note that you can optionally pass your content to the default slot of the `InfoWindow` component.
13 |
14 | ```vue
15 |
20 |
21 |
22 |
28 |
29 |
30 | Content passed through slot
31 |
32 |
33 |
34 | ```
35 |
36 |
37 |
43 |
44 |
45 | Content passed through slot
46 |
47 |
48 |
49 |
50 | ## Use with Marker
51 |
52 | You can nest the `InfoWindow` component inside the `Marker` component to display an info window when the marker is clicked.
53 |
54 | ```vue
55 |
60 |
61 |
62 |
68 |
69 |
70 |
71 |
72 |
Uluru
73 |
74 |
Uluru, also referred to as Ayers Rock, is a large
75 | sandstone rock formation in the southern part of the
76 | Northern Territory, central Australia. It lies 335 km (208 mi)
77 | south west of the nearest large town, Alice Springs; 450 km
78 | (280 mi) by road. Kata Tjuta and Uluru are the two major
79 | features of the Uluru - Kata Tjuta National Park. Uluru is
80 | sacred to the Pitjantjatjara and Yankunytjatjara, the
81 | Aboriginal people of the area. It has many springs, waterholes,
82 | rock caves and ancient paintings. Uluru is listed as a World
83 | Heritage Site.
Uluru, also referred to as Ayers Rock, is a large
109 | sandstone rock formation in the southern part of the
110 | Northern Territory, central Australia. It lies 335 km (208 mi)
111 | south west of the nearest large town, Alice Springs; 450 km
112 | (280 mi) by road. Kata Tjuta and Uluru are the two major
113 | features of the Uluru - Kata Tjuta National Park. Uluru is
114 | sacred to the Pitjantjatjara and Yankunytjatjara, the
115 | Aboriginal people of the area. It has many springs, waterholes,
116 | rock caves and ancient paintings. Uluru is listed as a World
117 | Heritage Site.
123 |
124 |
125 |
126 |
127 |
128 | ## Open and close the Info Window
129 |
130 | You can use `v-model` to manage the state of the info window programmatically or to know whether it's open or closed
131 |
132 | ```vue
133 |
144 |
145 |
146 |
152 |
153 |
154 |
This is the infowindow content
155 |
156 |
157 |
158 |
159 | ```
160 |
161 | ## Events
162 |
163 | You can listen for [the following events](https://developers.google.com/maps/documentation/javascript/reference/info-window#InfoWindow-Events) on the `InfoWindow` component.
164 |
165 |
170 |
--------------------------------------------------------------------------------
/docs/components/marker-cluster.md:
--------------------------------------------------------------------------------
1 |
32 |
33 | # Marker Cluster
34 |
35 | Use the `MarkerCluster` component to display a large number of markers on a map. It will combine markers of close proximity into clusters, and simplify the display of markers on the map. Can be used with the `Marker` or `CustomMarker` components.
36 |
37 | ## Usage
38 |
39 | Simply pass your `Marker`/`CustomMarker`(s) in the `default` slot of the `MarkerCluster` component.
40 |
41 | ```vue
42 |
73 |
74 |
75 |
81 |
82 |
87 |
88 |
89 |
90 | ```
91 |
92 |
93 |
99 |
100 |
105 |
106 |
107 |
108 |
109 | ## Options
110 |
111 | `MarkerCluster` accepts an `options` prop (an object) where you can configure `algorithm`, `onClusterClick`, and `renderer` from the [MarkerClustererOptions](https://googlemaps.github.io/js-markerclusterer/interfaces/MarkerClustererOptions.html) interface. Note that all these options are completely optional but non-reactive.
112 |
113 | ## Events
114 |
115 | You can listen for [the following events](https://googlemaps.github.io/js-markerclusterer/enums/MarkerClustererEvents.html) on the `MarkerCluster` component.
116 |
--------------------------------------------------------------------------------
/docs/components/marker.md:
--------------------------------------------------------------------------------
1 |
7 |
8 | # Marker
9 |
10 | Use the `Marker` component to draw markers, drop pins or any custom icons on a map.
11 |
12 | ## Options
13 |
14 | You can pass a [MarkerOptions](https://developers.google.com/maps/documentation/javascript/reference/marker#MarkerOptions) object to the `options` prop to configure your marker.
15 |
16 | ```vue
17 |
23 |
24 |
25 |
31 |
32 |
33 |
34 | ```
35 |
36 |
37 |
43 |
44 |
45 |
46 |
47 | ## Events
48 |
49 | You can listen for [the following events](https://developers.google.com/maps/documentation/javascript/reference/marker#Marker-Events) on the `Marker` component.
50 |
--------------------------------------------------------------------------------
/docs/components/polygon.md:
--------------------------------------------------------------------------------
1 |
21 |
22 | # Polygon
23 |
24 | Use the `Polygon` component to draw polgons (arbitrary number of sides) on a map.
25 |
26 | ## Options
27 |
28 | You can pass a [PolylgonOptions](https://developers.google.com/maps/documentation/javascript/reference/polygon#PolygonOptions) object to the `options` prop to configure your polyline.
29 |
30 | ```vue
31 |
50 |
51 |
52 |
58 |
59 |
60 |
61 | ```
62 |
63 |
64 |
70 |
71 |
72 |
73 |
74 | ## Events
75 |
76 | You can listen for [the following events](https://developers.google.com/maps/documentation/javascript/reference/polygon#Polygon-Events) on the `Polygon` component.
77 |
--------------------------------------------------------------------------------
/docs/components/polyline.md:
--------------------------------------------------------------------------------
1 |
20 |
21 | # Polyline
22 |
23 | Use the `Polyline` component to draw paths and arbitrary shapes on a map.
24 |
25 | ## Options
26 |
27 | You can pass a [PolylineOptions](https://developers.google.com/maps/documentation/javascript/reference/polygon#PolylineOptions) object to the `options` prop to configure your polyline.
28 |
29 | ```vue
30 |
48 |
49 |
50 |
56 |
57 |
58 |
59 | ```
60 |
61 |
62 |
68 |
69 |
70 |
71 |
72 | ## Events
73 |
74 | You can listen for [the following events](https://developers.google.com/maps/documentation/javascript/reference/polygon#Polyline-Events) on the `Polyline` component.
75 |
--------------------------------------------------------------------------------
/docs/components/rectangle.md:
--------------------------------------------------------------------------------
1 |
20 |
21 | # Rectangle
22 |
23 | Use the `Rectangle` component to draw simple rectangles on a map.
24 |
25 | ## Options
26 |
27 | You can pass a [RectangleOptions](https://developers.google.com/maps/documentation/javascript/reference/polygon#RectangleOptions) object to the `options` prop to configure your rectangle.
28 |
29 | ```vue
30 |
48 |
49 |
50 |
57 |
58 |
59 |
60 | ```
61 |
62 |
63 |
70 |
71 |
72 |
73 |
74 | ## Events
75 |
76 | You can listen for [the following events](https://developers.google.com/maps/documentation/javascript/reference/polygon#Rectangle-Events) on the `Rectangle` component.
77 |
--------------------------------------------------------------------------------
/docs/getting-started/index.md:
--------------------------------------------------------------------------------
1 |
7 |
8 | # Getting Started
9 |
10 | `vue3-google-map` offers a set of composable components for easy use of Google Maps in your Vue 3 projects.
11 |
12 | ## Installation
13 |
14 | ### NPM
15 |
16 | ```bash
17 | npm install vue3-google-map
18 | # OR
19 | yarn add vue3-google-map
20 | ```
21 |
22 | ### CDN
23 |
24 | Include the following script tag in your `index.html` (make sure to include it after Vue 3).
25 |
26 | ```html
27 |
28 | ```
29 |
30 | ## Your first map
31 |
32 | To construct a map using `vue3-google-map` you'll need to use the base `GoogleMap` component which receives your [Google Maps API key](https://developers.google.com/maps/documentation/javascript/get-api-key), styles (e.g. setting width and height), and any [MapOptions](https://developers.google.com/maps/documentation/javascript/reference/map#MapOptions) to configure your map ([see this](https://github.com/inocan-group/vue3-google-map/blob/develop/src/components/GoogleMap.vue#L36-L244) for a all the supported `MapOptions`).
33 | Other map features can be added to your map by passing map subcomponents ([Marker](/components/marker), [Polyline](/components/polyline), [Polygon](/components/polygon), [Rectangle](/components/rectangle), [Circle](/components/circle), or [CustomControl](/components/custom-control)) to the default slot of the `GoogleMap` component.
34 |
35 | The [the following events](https://developers.google.com/maps/documentation/javascript/reference/map#Map-Events) will be emitted by the `GoogleMap` component and can be listened to by using `@event_name`.
36 |
37 | ```vue
38 |
43 |
44 |
45 |
51 |
52 |
53 |
54 | ```
55 |
56 |
57 |
58 |
59 |
60 |
66 |
67 |
68 |
69 |
--------------------------------------------------------------------------------
/docs/images/map-1200.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inocan-group/vue3-google-map/34c2cc4bde5eca3efc8ecc8562d484b68d346307/docs/images/map-1200.jpg
--------------------------------------------------------------------------------
/docs/images/map-800.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inocan-group/vue3-google-map/34c2cc4bde5eca3efc8ecc8562d484b68d346307/docs/images/map-800.jpg
--------------------------------------------------------------------------------
/docs/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | prev: false
3 | next: false
4 | ---
5 |
6 | # vue3-google-map
7 |
8 | 
9 |
10 | `vue3-google-map` offers a set of composable components for easy use of Google Maps in your Vue 3 projects. This component assumes Vue3's reactivity and is not intended to work with Vue 2.
11 |
12 | To get start, please navigate to the [Getting Started](getting-started/index.md) section.
13 |
--------------------------------------------------------------------------------
/docs/shared/index.ts:
--------------------------------------------------------------------------------
1 | import { Loader } from "@googlemaps/js-api-loader";
2 |
3 | const loader = new Loader({
4 | apiKey: import.meta.env.VITE_GOOGLE_API_KEY,
5 | version: "weekly",
6 | libraries: ["visualization", "marker"],
7 | });
8 |
9 | export const apiPromise = import.meta.env.SSR ? Promise.resolve() : loader.load();
10 |
--------------------------------------------------------------------------------
/docs/themes/index.md:
--------------------------------------------------------------------------------
1 | # Themes
2 |
3 | `vue3-google-map` comes with a curated set of default themes for you to use. You can also define custom styles utilizing the Google Maps API.
4 |
5 | ## Default Themes
6 |
7 | To use a default theme simply pass the theme's name to the `theme` prop of the `GoogleMap` component. The available themes are:
8 |
9 | - `aubergine`
10 | - `dark`
11 | - `grey`
12 | - `minimal`
13 | - `retro`
14 | - `roadways`
15 | - `roadwaysMinimal`
16 | - `ultraLight`
17 |
18 | ```vue
19 |
20 |
21 |
22 |
26 |
27 |
28 |
43 |
44 |
51 | ```
52 |
53 | \
54 |
55 |
56 | ## Custom Styles
57 |
58 | ::: warning
59 | Please be aware that if you specify a default theme that it will override any custom styles you define.
60 | :::
61 |
62 | Alternatively you can define your own styles by passing them to the `styles` prop of the `GoogleMap` component. Please refer to the [Google Maps documentation](https://developers.google.com/maps/documentation/javascript/reference/map#MapOptions.styles) on custom styles.
63 |
--------------------------------------------------------------------------------
/netlify.toml:
--------------------------------------------------------------------------------
1 | [build]
2 | # Directory that contains the deploy-ready HTML files and assets generated by
3 | # the build.
4 | publish = "docs/.vitepress/dist"
5 |
6 | # Default build command.
7 | command = "yarn docs:build"
8 |
9 | [[plugins]]
10 | package = "./docs/build"
11 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "vue3-google-map",
3 | "version": "0.22.0",
4 | "license": "MIT",
5 | "repository": {
6 | "type": "git",
7 | "url": "https://github.com/inocan-group/vue3-google-maps.git"
8 | },
9 | "homepage": "https://vue3-google-map.com",
10 | "description": "A set of composable components for easy use of Google Maps in your Vue 3 projects.",
11 | "unpkg": "dist/index.umd.js",
12 | "jsdelivr": "dist/index.umd.js",
13 | "main": "dist/index.cjs",
14 | "module": "dist/index.mjs",
15 | "files": [
16 | "dist"
17 | ],
18 | "exports": {
19 | ".": {
20 | "import": "./dist/index.mjs",
21 | "require": "./dist/index.cjs",
22 | "types": "./dist/types/index.d.ts"
23 | },
24 | "./themes": {
25 | "import": "./dist/themes/index.mjs",
26 | "require": "./dist/themes/index.cjs",
27 | "types": "./dist/types/themes/index.d.ts"
28 | }
29 | },
30 | "typesVersions": {
31 | "*": {
32 | "*": [
33 | "dist/types/index.d.ts"
34 | ],
35 | "themes": [
36 | "dist/types/themes/index.d.ts"
37 | ]
38 | }
39 | },
40 | "scripts": {
41 | "dev": "vite",
42 | "prepare": "pnpm run build",
43 | "clean": "rimraf dist/**/*",
44 | "lint": "npx eslint --ext .ts,.vue src dev docs --fix",
45 | "build:umd": "node ./scripts/build-umd.js",
46 | "build": "pnpm clean && vue-tsc --declaration --emitDeclarationOnly --project tsconfig.build.json && vite build && pnpm build:umd",
47 | "docs": "vitepress dev docs",
48 | "docs:dev": "vitepress dev docs",
49 | "docs:build": "vitepress build docs",
50 | "docs:serve": "vitepress serve docs",
51 | "release": "standard-version"
52 | },
53 | "dependencies": {
54 | "@googlemaps/js-api-loader": "^1.16.2",
55 | "@googlemaps/markerclusterer": "^2.4.0",
56 | "fast-deep-equal": "^3.1.3"
57 | },
58 | "devDependencies": {
59 | "pnpm": "^8.7.6",
60 | "@types/google.maps": "^3.58.1",
61 | "@typescript-eslint/eslint-plugin": "^4.33.0",
62 | "@typescript-eslint/parser": "^4.33.0",
63 | "@vitejs/plugin-vue": "^4.3.1",
64 | "@vue/eslint-config-prettier": "^6.0.0",
65 | "@vue/eslint-config-typescript": "^7.0.0",
66 | "eslint": "^7.32.0",
67 | "eslint-config-prettier": "^8.10.0",
68 | "eslint-plugin-prettier": "^3.4.1",
69 | "eslint-plugin-vue": "^7.20.0",
70 | "prettier": "^2.8.8",
71 | "rimraf": "^5.0.1",
72 | "standard-version": "^9.5.0",
73 | "typescript": "^5.1.6",
74 | "vite": "^4.5.3",
75 | "vite-plugin-css-injected-by-js": "^3.2.1",
76 | "vitepress": "^1.0.0-rc.40",
77 | "vue": "^3.3.4",
78 | "vue-tsc": "^1.8.8"
79 | },
80 | "peerDependencies": {
81 | "vue": "^3"
82 | },
83 | "engines": {
84 | "node": ">=16.11.0"
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/playground/App.vue:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
11 |