Integrating Google Maps in vue.js

I’d suggest using npm google-maps instead of adding a script in index.html. You might not need to call google-maps API in every pages, and I’d say it’s better to use Webpack properly. You can use npm install google-maps

import GoogleMapsLoader from 'google-maps'

mounted: function () {
  GoogleMapsLoader.load(function(google) {
    let map = new google.maps.Map(document.getElementById('map'), {
      zoom: 15,
      center: position
    })
  })
}

Leave a Comment