npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vue-google-maps

v0.1.21

Published

This is a google map component for Vue.js

Downloads

566

Readme

vue-google-maps

Demo:

Demo in production

Showcase with a lot of features

Presentation

If you want to write google map this way :

<map
  :center="{lat:10, lng:10}"
  :map-type-id="terrain"
  :zoom="7"
></map>

Or use the power of Vue.js within a google map like this:

<template>
  <map
    :center="center"
    :zoom="7"
  >
    <marker 
      v-for="m in markers"
      :position.sync="m.position"
      :clickable="true"
      :draggable="true"
      @g-click="center=m.position"
    ></marker>
  </map>
</template>

<script>
  import {load, Map, Marker} from 'vue-google-maps'
  
  load('YOUR_API_TOKEN','OPTIONAL VERSION NUMBER')
  
  export default {
    data () {
      return {
        center: {lat: 10.0, lng: 10.0},
        markers: [{
          position: {lat: 10.0, lng: 10.0}
        }, {
          position: {lat: 11.0, lng: 11.0}
        }]
      }
    }
  }
</script>

Example Project

You can see an project example here.

It uses webpack and vue-loader and was "forked" from the vue-loader-example project

Installation

With npm (Recommended)

npm install vue-google-maps

You can append --save or --save-dev to add it to your depency (if yor project also uses npm)

Manually

Just download the index.js file on the root directory of this repository

Basic usage

Reference vue-google-maps into your project

If you are using a cool bundler (recommended) you can just do :

import {load, Map, Marker} from 'vue-google-maps'

Or if you prefer the older ES5 syntax:

const VueGoogleMap = require('vue-google-maps')

Standalone / CDN

If you are not using any bundler (and you should feel bad). You can just reference the file in a script tag. The library will be available in a global object called VueGoogleMap. However you will need to include Vue and Lodash beforehand:

<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/1.0.17/vue.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.6.1/lodash.min.js"></script>
<script src="dist/vue-google-maps.js"></script>

</head>
<body>

<google-map style="width: 100%; height: 100%; position: absolute; left:0; top:0"
    :center="{lat: 1.38, lng: 103.8}"
    :zoom="12"
>

</google-map>

<script>
VueGoogleMap.load({
    'key': 'YOUR_API_KEY',
})
Vue.component('google-map', VueGoogleMap.Map);
new Vue({
    el: 'body',
});

</script>

</body>

Set your api key

To enable any vue-google-maps components you need to set your api token:

load({
  key: 'YOUR_API_TOKEN',
  v: '3.24',                // Google Maps API version
  // libraries: 'places',   // If you want to use places input
})
// OR (depending on how you refereced it)
VueGoogleMap.load({ ... })

The parameters are passed in the query string to the Google Maps API, e.g. to set the version, libraries, or for localisation.

Full documentation

Note on events

All events are prefixed with g-. Example : g-click so it does not interfere with DOM events.

Documentation is up to date: take a look at the wiki

Sponsor

This component is sponsored by PapayaPods. Feel free to check out vue-google-maps in production !!