Lazy Loading Google Maps

I created a really lean page and then I had to embed Google Maps which made multiple requests and made the page slower. Not all users reach to the viewport with the map and very few of the ones who reach there use it interactively. So, this is how I implemented lazy-loading of the maps.
  1. Do not load anything if the user isn't going to view it.
  2. Show users a static map (image) if they reach the viewport.
  3. Load a dynamic map only if they want to interact (i.e. click on the static map).
Following is a sample implementation in Vue.js. Lazy-loading of image is done via LazyLoad which reads the data-src attribute and writes src attribute lazily.
        <div v-if="isStatic" class="has-text-centered" id="static-map-wrapper">
            <img :data-src="staticUrl" alt="Map" title="Click to browse" @click="loadDynamic"/>
        <div v-else class="g-map" id="g-map"></div>

  export default {
    props: {
      'lat': {}, 'lng': {}, 'zoom': {default: 14}
    data() {
      return {
        isStatic: true,
        staticWidth: 640,
        staticHeight: 400,
        key: config.googleMapKey,
    computed: {
      staticUrl() {
        return `${},${this.lng}&zoom=${this.zoom}&maptype=roadmap
    mounted() {
      window.initMap = () => {
        const el = document.getElementById('g-map');
        const latLng = new google.maps.LatLng(, this.lng);
        const options = {
          zoom: this.zoom,
          center: latLng
        const map = new google.maps.Map(el, options);
        const marker = new google.maps.Marker({
          position: latLng,

    methods: {
      loadDynamic() {
        this.isStatic = false;
        if ( && google.maps) {
        } else {

<style scoped>
    .g-map {
        height: 400px;
        margin: 0 auto;
        background: #ebe8de;
Example usage of the component:
<GMap lat="27.6861537" lng="85.3295763"/>