GuillaumeLeclerc / vue-google-maps

Google maps component for vue with 2-way data binding
560 stars 653 forks source link

Load : Consider testing if is already loaded. #109

Open otiagovicente opened 7 years ago

otiagovicente commented 7 years ago

I'm using vue-google-maps in a large application, and i have to test in every component if maps are already loaded. I can handle this with this:

if (!(typeof google === 'object' && typeof google.maps === 'object')) {
                    load(Maps.maps_key, Maps.maps_version);
}

However, it would be nice if Vue Google Maps do it. It would not affect any other on production applications. This is my suggestion, thank you for the awesome wrapper, it makes living worth.

brunosmagna commented 7 years ago

Hey, i have the same problem. Great Solution. However, it would be nice if Vue Google Maps do it natively. thank you for the awesome wrapper.

xkjyeah commented 7 years ago

What kind of components are these?

Vue.component('someComponent', MapComponent.extend({
    deferredReady() {
        console.log(this.$map)
    }
})
import {loaded} from 'vue-google-maps'

loaded.then(() => {
    console.log(google.maps)
})