diegoazh / gmap-vue

A wrapper component for consuming Google Maps API built on top of Vue. Fork of the popular vue-google-maps plugin.
https://diegoazh.github.io/gmap-vue/
173 stars 51 forks source link

Bug: gmap-vue breaks in Nuxt unless defined as client side only #263

Closed davydnorris closed 2 years ago

davydnorris commented 2 years ago

Please complete all sections that you can but please don't remove any section, otherwise the bot will close your issue because it doesn't meet our issue template (you can remove this comment)

Describe the bug

A default install and configuration of gmap-vue into a Nuxt project as per the documentation will fail with the message "Document is not defined" when a page containing a map is displayed. This is due to the default Nuxt behaviour of server side rendering, and the fact that the MapLayer component has a CSS style section in it.

To reproduce

Steps to reproduce the behavior:

  1. Create a new Nuxt project
  2. Add gmap-vue library, and create a plugin file as per the dcumentation
  3. Add the plugin and the transpile directive to nuxt.config.js as per the documentation
  4. Add a gmap-map component to a page
  5. Run the application. It will compile without error
  6. Navigate to the page containing the map.

Expected behavior

The map is displayed correctly

Current behavior

The page will not display and will show a "Document is not defined" error

Screenshots

N/A

Desktop (please complete the following information)

Smartphone (please complete the following information)

Additional context

The issue is fixed by specifying that gmap-vue is a client side plugin. This is done via the following in nuxt.config.js:

  plugins: [
    { src: '@/plugins/gmap-vue', mode: 'client' }
  ],

The documentation on setting up in Nuxt should be updated to show this

Versions

Package manager

Plugin version

close-issue-app[bot] commented 2 years ago

This issue is closed because it does not meet our issue template. Please read it.