question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to use in nuxt3

See original GitHub issue

I tried to use vue-google-maps in nuxt3.

plugins/vueGoogleMaps.ts

import VueGoogleMaps from '@fawmi/vue-google-maps'

export default defineNuxtPlugin((app) => {
    app.vueApp.use(VueGoogleMaps, {
        load: {
          key: "my-api-key",
          language:'ja'
        }
      });
});

But it doesn’t work.

When I open map page, the message below show;

[vite dev] Error loading external "/Users/myName/Desktop/nuxt-vuetify-sample/node_modules/@fawmi/vue-google-maps/src/utils/env.js".

Could you show how to use in nuxt3?

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:6
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

9reactions
BapRxcommented, Jul 7, 2022

Hi, I got it working with the following configuration (@fawmi/vue-google-maps": "^0.9.72):

nuxt/nuxt.config.ts

export default defineNuxtConfig({
  build: { transpile: ["@fawmi/vue-google-maps"] },
  runtimeConfig: {
    public: { GOOGLE_MAPS_API_KEY: process.env.GOOGLE_MAPS_API_KEY },
  },
})

nuxt/plugins/vueGoogleMaps.ts

import VueGoogleMaps from "@fawmi/vue-google-maps"

export default defineNuxtPlugin((nuxtApp) => {
  const config = useRuntimeConfig().public
  nuxtApp.vueApp.use(VueGoogleMaps, {
    load: {
      key: config.GOOGLE_MAPS_API_KEY,
    },
  })
})

nuxt/pages/example.vue

<template>
[...]
      <div class="mb-20">
        <GMapMap
          :center="center"
          :zoom="15"
          :options="{
            zoomControl: true,
            mapTypeControl: false,
            scaleControl: false,
            streetViewControl: false,
            rotateControl: false,
            fullscreenControl: true,
          }"
          style="width: 500px; height: 300px; margin: auto"
        >
          <GMapMarker
            :key="index"
            v-for="(marker, index) in markers"
            :position="marker.position"
            :clickable="true"
            :draggable="true"
            @click="openMarker(marker.id)"
          >
            <GMapInfoWindow
              :closeclick="true"
              @closeclick="openMarker(null)"
              :opened="openedMarkerID === marker.id"
            >
              <div>{{ marker.description }}</div>
            </GMapInfoWindow>
          </GMapMarker>
        </GMapMap>
      </div>
[...]
</template>

<script>
export default {
  name: "App",
  data() {
    return {
      openedMarkerID: null,
      center: { lat: 48.8773406, lng: 2.327774 },
      markers: [
        {
          description: "Google France",
          id: "1",
          position: {
            lat: 48.8773406,
            lng: 2.327774,
          },
        },
      ],
    }
  },
}
</script>
0reactions
Phylloncommented, Dec 21, 2022

It imports style sheets from google fonts, which violates the EU’s GDPR privacy act. Has anyone figured out, if self-hosting the respective fonts will prevent the module from downloading fonts?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Nuxt 3 first steps. - ITNEXT
Now, during my research, I found a lot of tutorials on how to connect Nuxt 3 with new modules like i18n, Algolia, or...
Read more >
How to use Vuetify with Nuxt 3 - Cody Bontecou
Get Vuetify to work with Nuxt 3 with this quick tutorial. ... Start by creating a Nuxt 3 project if you do not...
Read more >
Getting started with Nuxt 3 - Section.io
Nuxt 3 is a Hybrid Vue Framework that allows us to use Vue.js and, most importantly, Vue.js 3 to build server-side rendered applications....
Read more >
How to use Select2 in Nuxt3 - Stack Overflow
I have spent few days to do this, but failed. Finally I made my own npm package. Think might be useful for others,...
Read more >
nuxt3 examples - CodeSandbox
Learn how to use nuxt3 by viewing and forking nuxt3 example apps on CodeSandbox.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found