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/
172 stars 51 forks source link

Bug: GoogleMapsCallback is not a function #284

Closed joshstrange closed 1 year ago

joshstrange 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

If you don't have a GmapMap component on your page (or if it's not visible/rendered) and you try to use dynamic importing (googleMapsApiInitializer) then you might see this error:

locations:1 Uncaught (in promise) _.qe {message: 'GoogleMapsCallback is not a function', stack: 'Error\n    at _.qe.captureStackTrace (https://maps/.…es%2Cgeometry&callback=GoogleMapsCallback:235:269', name: 'InvalidValueError'}

To reproduce

Steps to reproduce the behavior:

  1. Initialize the plugin but pass in dynamicLoad: false, to the config
  2. Call googleMapsApiInitializer without a GmapMap instance on your page
  3. See error

Expected behavior

I would expect that initializing the plugin should be when it sets window.GoogleMapsCallback instead of it apparently being only when you use the GmapMap component.

Current behavior

If you don't use the GmapMap component then after Google maps loads it will throw an error (the google maps JS code throws the error) because it can't find window.GoogleMapsCallback

locations:1 Uncaught (in promise) _.qe {message: 'GoogleMapsCallback is not a function', stack: 'Error\n    at _.qe.captureStackTrace (https://maps/.…es%2Cgeometry&callback=GoogleMapsCallback:235:269', name: 'InvalidValueError'}

Screenshots

N/A

Desktop (please complete the following information)

Smartphone (please complete the following information)

Additional context

It would be useful to add something to the docs about this and/or actually register that callback at time of plugin initialization instead of waiting until you load a GmapMap component.

Versions

Package manager

Plugin version

escobarAndre commented 1 year ago

Same here

FixMiller commented 1 year ago

same here, node: v16.17.0, npm: 8.19.2

diegoazh commented 1 year ago

Maintenance of the plugin for Vue v2 is stopped. Please migrate to the new version for Vue v3.