Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read property 'setBounds' of null when using vueGoogleMapsCompatibility #112

Open
toddb opened this issue Oct 27, 2020 · 0 comments

Comments

@toddb
Copy link

toddb commented Oct 27, 2020

Error affects v2.0.4 with vueGoogleMapsCompatibility:

Cannot read property 'setBounds' of null

Steps to reproduce:

  • initialise via README approach
import Vue from 'vue';
import * as VueGoogleMaps from 'vue2-google-maps';
import VuetifyGoogleAutocomplete from 'vuetify-google-autocomplete';

// @see https://www.npmjs.com/package/vue2-google-maps
Vue.use(VueGoogleMaps, {
    load: {
        key: 'xxxxxxxxs',
        // This is required to use the Autocomplete plugin
        libraries: 'places', // 'places,drawing,visualization'
    },
});

Vue.use(VuetifyGoogleAutocomplete, {
    /*
      not used as loaded with component
      apiKey: key,
    */
    vueGoogleMapsCompatibility: true,
});
  • add your component to the page
  • load up the vue page and get an early focus on the field (the goal is to active this.geoLocate() asap.

The issue is that the lazy load promise of gmaps is not yet complete, so this.autocomplete is not yet intialised. Thus the error occurs:

           this.setupGmapApi(() => {
              const circle = new window.google.maps.Circle({
                center: geolocation,
                radius: position.coords.accuracy,
              });
              this.autocomplete.setBounds(circle.getBounds());  // autocomplete not yet initialised from setupGoogle()
              this.geolocateSet = true;
            });
          });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant