v-maps

[![Build Status](https://travis-ci.org/FelipeBohnertPaetzold/v-maps.svg?branch=master)](https://travis-ci.org/FelipeBohnertPaetzold/v-maps) <a href="https://npmcharts.com/compare/v-maps?minimal=true"><img src="https://img.shields.io/npm/dm/v-maps.svg" alt

Usage no npm install needed!

<script type="module">
  import vMaps from 'https://cdn.skypack.dev/v-maps';
</script>

README

v-maps

Build Status Downloads Version License

A simple Google Maps component for Vue

Live Demo

Install

run:

yarn add v-maps

or:

npm install v-maps --save

Usage

  • Globally registration:

      import Vue from 'vue'
      import VMaps from 'v-maps'
      
      // { key: string, version?: string, libraries?: Array<string> }
      const googleApiOptions = { key: 'YOUR_GOOGLE_MAPS_API_KEY' }
      Vue.use(VMaps, googleApiOptions)
    
    • using global registration in component
    <template>
      <v-map :center="{ lat: -23.4070511, lng: -51.9428867 }" />
    </template>
    
    • using global registration map with markers
    <template>
      <v-map :center="center">
        <v-marker :position="center" />
      </v-map>
    </template>
    
    <script>
      export default {
        computed: {
          center() {
            return { lat: -23.4070511, lng: -51.9428867 }
          }        
        }
      }
    </script>
    
    • using global registration map with polygon
    <template>
      <v-map :center="center">
        <v-polygon :paths="polygonPaths" />
      </v-map>
    </template>
    
    <script>
      export default {
        data() {
          return { polygonPaths: [] }
        },
    
        computed: {
          center() {
            return { lat: -23.4070511, lng: -51.9428867 }
          }        
        }
      }
    </script>
    
    • using global registration map with polyline
    <template>
      <v-map :center="center">
        <v-polyline :path="polylinePath" />
      </v-map>
    </template>
    
    <script>
      export default {
        data() {
          return { polylinePath: [] }
        },
    
        computed: {
          center() {
            return { lat: -23.4070511, lng: -51.9428867 }
          }        
        }
      }
    </script>
    
  • Locally registration

    <template>
      <v-map :center="center" api-key="YOUR_GOOGLE_MAPS_API_KEY">
        <v-marker :position="center" />
        <v-polygon :paths="polygonPaths" />
        <v-polyline :path="polylinePath" />
      </v-map>
    </template>
    
    <script>
      import { VMap, VMarker, VPolygon, VPolyline } from 'v-maps'
    
      export default {
        data() {
          return { polygonPaths: [], polylinePath: [] }
        },
    
        computed: {
          center() {
            return { lat: -23.4070511, lng: -51.9428867 }
          }        
        },
        components: { VMarker, VMap, VPolygon, VPolyline }
      }
    </script>
    

Props

Events

  • v-map(for more details check the google documentation in https://developers.google.com/maps/documentation/javascript/events)

    Vue Event Params Native google map event
    bounds-changed map, event bounds_changed
    center-changed map, event center_changed
    click map, event click
    double-click map, event dblclick
    drag map, event drag
    drag-end map, event dragend
    drag-start map, event dragstart
    heading-changed map, event heading_changed
    idle map, event idle
    map-type-id-changed map, event maptypeid_changed
    mouse-move map, event mousemove
    mouse-out map, event mouseout
    mouse-over map, event mouseover
    projection-changed map, event projection_changed
    resize map, event resize
    right-click map, event rightclick
    tiles-loaded map, event tilesloaded
    tilt-changed map, event tilt_changed
    zoom-changed map, event zoom-changed
  • v-marker

    Vue Event Params Info
    click None This only works if the marker has no info window
  • v-polygon

    Vue Event Params Native google map event
    path-changed Current paths of polygon
  • v-polyline

    Vue Event Params Native google map event
    path-changed Current paths of polyline