File tree Expand file tree Collapse file tree 1 file changed +51
-0
lines changed Expand file tree Collapse file tree 1 file changed +51
-0
lines changed Original file line number Diff line number Diff line change @@ -245,6 +245,57 @@ const MyMap: React.FC = () => {
245245export default MyMap ;
246246```
247247
248+ ### Vue
249+
250+ ``` vue
251+ <script lang="ts" setup>
252+ import { ref, shallowRef, useTemplateRef } from 'vue'
253+ import { GoogleMap } from '@capacitor/google-maps'
254+
255+ const mapRef = useTemplateRef<HTMLElement>('mapRef')
256+ const newMap = shallowRef<GoogleMap>()
257+
258+ async function createMap() {
259+ if (!mapRef.value) return
260+
261+ newMap.value = await GoogleMap.create({
262+ id: 'my-cool-map',
263+ element: mapRef.value,
264+ apiKey: import.meta.env.VITE_YOUR_API_KEY_HERE,
265+ config: {
266+ center: {
267+ lat: 33.6,
268+ lng: -117.9,
269+ },
270+ zoom: 8,
271+ },
272+ })
273+ }
274+ </script>
275+
276+ <template>
277+ <capacitor-google-map
278+ ref="mapRef"
279+ style="display: inline-block; width: 275px; height: 400px"
280+ ></capacitor-google-map>
281+ <button @click="createMap()">Create Map</button>
282+ </template>
283+
284+ ```
285+
286+ make sure you need enable [ recognize native custom elements] ( https://vuejs.org/guide/extras/web-components.html#using-custom-elements-in-vue ) like
287+
288+ ``` ts
289+ // vite.config.mts > plugins
290+ Vue ({
291+ template: {
292+ compilerOptions: {
293+ isCustomElement : (tag ) => tag .startsWith (' capacitor-' )
294+ },
295+ },
296+ }),
297+ ```
298+
248299### Javascript
249300
250301``` html
You can’t perform that action at this time.
0 commit comments