GmapVue - Google Maps for Vue 2

3.5.4 · active · verified Sun Apr 19

GmapVue is an actively maintained Google Maps component library specifically designed for Vue 2 applications, currently at version 3.5.4. It originated as a fork of the popular but unmaintained `vue2-google-maps` project, ensuring continued support and development for Vue 2 users. The library provides a suite of components for integrating various Google Maps features, including maps, markers, polygons, and autocomplete functionalities, all within a declarative Vue syntax. Recent releases, labeled `gmv3_vX.Y.Z` in its internal changelog, indicate ongoing bug fixes and feature enhancements, with multiple updates in 2024 and 2025. Its key differentiator is its dedicated focus on Vue 2 compatibility and active maintenance, filling a gap left by its predecessor, and offering a robust solution for developers needing Google Maps in their Vue 2 projects.

Common errors

Warnings

Install

Imports

Quickstart

This example demonstrates how to install GmapVue as a Vue plugin, initialize it with a Google Maps API key, and render a basic map with a draggable marker. The marker's position updates on drag.

import Vue from 'vue';
import GmapVue from 'gmap-vue';

// Replace 'YOUR_GOOGLE_MAPS_API_KEY' with your actual API key
Vue.use(GmapVue, {
  load: {
    key: process.env.VUE_APP_GOOGLE_MAPS_API_KEY ?? 'YOUR_GOOGLE_MAPS_API_KEY',
    libraries: 'places' // Optional: Load additional libraries like 'places' for autocomplete
  },
  installComponents: true, // This is true by default, explicitly stating for clarity
});

new Vue({
  el: '#app',
  template: `
    <div style="width: 100%; height: 500px;">
      <GmapMap
        :center="{lat: -34.397, lng: 150.644}"
        :zoom="12"
        map-type-id="terrain"
        style="width: 100%; height: 100%"
      >
        <GmapMarker
          :position="markerPosition"
          :clickable="true"
          :draggable="true"
          @click="center = markerPosition"
          @dragend="updateMarkerPosition"
        />
      </GmapMap>
    </div>
  `,
  data() {
    return {
      center: {lat: -34.397, lng: 150.644},
      markerPosition: {lat: -34.397, lng: 150.644}
    }
  },
  methods: {
    updateMarkerPosition(event) {
      this.markerPosition = {
        lat: event.latLng.lat(),
        lng: event.latLng.lng()
      };
    }
  }
});

view raw JSON →