This is the Vue 2.x port of vue-google-maps!
If you have used vue-google-maps with Vue 1.x before, refer to Upgrading.
npm install vue2-google-maps
In your project:
For Nuxt.js projects, please import VueGoogleMaps in the following manner:
This is required for successful server-side rendering.
(Note: as of v0.8.1, you should add
src/main to the path)
dist/vue-google-maps.js file and include it from your HTML.
If you use this method, Vue 2.1.x is required.
If you want to write google map this way :
Or use the power of Vue.js within a google map like this:
vue-router/ components that change their visibility
If you are using
vue-router, you may encounter the problem where
you see greyed-out areas because you haven't
triggered a resize
on the map after its visibility has changed.
You have two options:
(Version 0.5.0) Run
For example, you can write the following to force all maps on your page to re-render:
watch:'$route'to from// Call resizePreserveCenter() on all mapsVue$gmapDefaultResizeBus
If you wish to be more selective about which maps receive the
event, you can define
resizeBus individually on each map. (See API).
This will disconnect the map from
vm.$refs.<YOUR_MAP_HERE>.resizePreserveCenter() on every map
instance that you have
There is a non-comprehensive test for the DeferredReady mixin. More automated tests should be written to help new contributors.
Meanwhile, please test your changes against the suite of examples.
Improvements to the tests are welcome :)
If you are not using any bundler, include
The library will be available in a global object called
However you will need to include Vue and Lodash beforehand:
To enable any
vue-google-maps components you need to set your api token: