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

vuejs-google-maps

v0.2.0

Published

A set of Google Map components for VueJs

Downloads

1,448

Readme

vuejs-google-map

Google Map components and integration for VueJs

NPM version Dependency Statusnpm npm

This package is under active development, the documentation is not complete yet, so if is missing something open a request or look at the source code.

Installation

npm i vuejs-google-maps
yarn add vuejs-google-maps

Usage

Before starting you need a Google API key from the developer console, once you obtained your key, import the module in your application and register it as plugin:

import Vue from 'vue'
import VueGoogleMap from 'vuejs-google-maps'
import 'vuejs-google-maps/dist/vuejs-google-maps.css'

Vue.use(VueGoogleMap, {
    load: {
        apiKey: 'your-api-key',
        libraries: [/* rest of libraries */]
    }
})

♻️ Usage with Nuxt.js

Add vuejs-google-maps/nuxt to modules section of nuxt.config.js

export default {
    modules: [
        // Simple usage
        'vuejs-google-maps/nuxt',
        // Passing options in module configuration
        ['vuejs-google-maps/nuxt', {apiKey: 'xxxxxx', libraries: [/* rest of libraries */]}]
    ],
    // Passing options in module top level configuration
    googleMaps: {apiKey: 'xxxxxx', libraries: [/* rest of libraries */]}
}

This module tries to map GoogleMap with Vue components as much as possible so any of the options available on the original GoogleMap class will be available as component props and all the events emitted will be mapped to component events.

Components

Here a list of the available components that you can use with this plugin, click on them to discover more about the usage and see examples. If you are interested to see a real life use checkout the example folder which contains the source code of the website.

Marker

The Google Map Marker element require to be inside a <google-map> component., it support the default slot.


<template>
  <google-map-marker
      title="String"
      label="String|Object"
      clickable="Boolean"
      draggable="Boolean"
      visible="Boolean"
      z-index="Number"
      click="Function"
      dblclick="Function"
      rightclick="Function"
      drag="Function"
      dragstart="Function"
      dragend="Function"
      mouseup="Function"
      mousedown="Function"
      mouseover="Function"
      mouseout="Function"
  />
</template>

AutoComplete

The AutoComplete component does not require to be inside a <google-map> component, it can be used anyway inside your app. It display an input and optionally the autocomplete controls, when a place is selected the place-changed event is triggered with the result.


<template>
  <google-map-autocomplete
      model="String"
      types="Array"
      controls="Boolean"
      update-map="Boolean"
      place-changed="Function"
  />
</template>

Autocomplete props

  • Example:
const center = { lat: 50.064192, lng: -130.605469 };
// Create a bounding box with sides ~10km away from the center point
const defaultBounds = {
  north: center.lat + 0.1,
  south: center.lat - 0.1,
  east: center.lng + 0.1,
  west: center.lng - 0.1,
};
const options = {
  bounds: defaultBounds,
  componentRestrictions: { country: "us" },
  fields: ["address_components", "geometry", "icon", "name"],
  strictBounds: false,
  types: ["establishment"],
};

<template>
  <div class="info-windows">
    <google-map id="map" ref="Map">
      <google-map-marker
          :key="index"
          v-for="(infoWindow, index) in infoWindowsList"
          :position="infoWindow.position"
          :key="index"
          @click="toggleInfoWindow(infoWindow)"
      />
      <google-map-infowindow
          :position="infoWIndowContext.position"
          :show.sync="showInfo"
          :options="{maxWidth: 300}"
          @info-window-clicked="infoClicked"
      >
        <h4>{{infoWindowContext.title}}</h4>
        <p>{{infoWindowContext.description}}</p>
      </google-map-infowindow>
    </google-map>
  </div>
</template>

<script>
import cities from '~/assets/cities.json'

export default {
  data() {
    return {
      showInfo: false,
      infoWindowContext: {
        position: {
          lat: 44.2899,
          lng: 11.8774
        }
      },
      infoWindowsList: cities
    }
  },
  methods: {
    toggleInfoWindow(context) {
      this.infoWIndowContext = context
      this.showInfo = true
    },
    infoClicked(context) {
      console.log(context)
    }
  }
}
</script>

Added

@info-window-clicked($event) to info-windows


Development

If you want to contribute in the development clone or fork the repository, than install all the dependencies:

npm install
yarn install

Create a .env file containing the VUE_APP_GOOGLE_APIKEY variable with your valid API key:

VUE_APP_GOOGLE_APIKEY=my-apy-key

License

This package is under the MIT License.