Skip to content

Latest commit

 

History

History
241 lines (195 loc) · 8.88 KB

README.md

File metadata and controls

241 lines (195 loc) · 8.88 KB

v-maps

Build Status Downloads Version License

A simple Google Maps component for Vue

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