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 🙏

© 2025 – Pkg Stats / Ryan Hefner

google-map-ts-vue3

v1.3.0

Published

Google Map Vue3 Component

Readme

google-map-ts-vue3

npm version CI E2E Tests TypeScript License: MIT

A Vue 3 component for integrating Google Maps with full TypeScript support.

This library provides a declarative interface for rendering Google Maps with markers, polylines, polygons, circles, and rectangles, utilizing the latest Google Maps JavaScript API features including Advanced Markers.

Installation

npm install google-map-ts-vue3

Usage

Basic Example

<script setup lang="ts">
import { GoogleMap } from "google-map-ts-vue3";
</script>

<template>
  <GoogleMap
    apiKey="YOUR_GOOGLE_MAPS_API_KEY"
    :options="{
      center: { lat: 35.1, lng: 135.1 },
      zoom: 5,
      mapId: 'DEMO_MAP_ID'
    }"
  />
</template>

Complete Example with Overlays

<script setup lang="ts">
import { GoogleMap } from "google-map-ts-vue3";
</script>

<template>
  <GoogleMap
    apiKey="YOUR_GOOGLE_MAPS_API_KEY"
    :options="{
      center: { lat: 35.1, lng: 135.1 },
      zoom: 5,
      mapId: 'DEMO_MAP_ID'
    }"
    :markers="[
      {
        position: { lat: 35.1, lng: 135.1 },
        title: 'Location 1'
      },
      {
        position: { lat: 37.1, lng: 139.1 },
        title: 'Location 2'
      }
    ]"
    :polylines="[
      {
        path: [
          { lat: 35.1, lng: 135.1 },
          { lat: 37.1, lng: 139.1 }
        ],
        geodesic: true,
        strokeColor: '#ff0000',
        strokeOpacity: 1.0,
        strokeWeight: 2
      }
    ]"
    :polygons="[
      {
        paths: [
          { lat: 30, lng: 140 },
          { lat: 31, lng: 141 },
          { lat: 30, lng: 145 },
          { lat: 33, lng: 140 }
        ],
        strokeColor: '#ff0000',
        strokeOpacity: 0.8,
        strokeWeight: 3,
        fillColor: '#ff0000',
        fillOpacity: 0.35
      }
    ]"
    :circles="[
      {
        center: { lat: 39.1, lng: 140.1 },
        radius: 100000,
        strokeColor: '#ff0000',
        strokeOpacity: 0.8,
        strokeWeight: 2,
        fillColor: '#ff0000',
        fillOpacity: 0.35
      }
    ]"
    :rectangles="[
      {
        bounds: {
          north: 30,
          south: 33,
          east: 133,
          west: 130
        },
        strokeColor: '#ff0000',
        strokeOpacity: 0.8,
        strokeWeight: 2,
        fillColor: '#ff0000',
        fillOpacity: 0.35
      }
    ]"
  />
</template>

API Reference

Props

| Property | Type | Required | Default | Description | |------------------------|-----------------------------------------------------|----------|----------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------| | apiKey | string | Yes | - | Google Maps API key. Obtain from Google Cloud Console | | options | google.maps.MapOptions | Yes | - | Map configuration options. See MapOptions | | markers | google.maps.marker.AdvancedMarkerElementOptions[] | No | [] | Array of advanced marker configurations. See AdvancedMarkerElementOptions | | polylines | google.maps.PolylineOptions[] | No | [] | Array of polyline configurations. See PolylineOptions | | polygons | google.maps.PolygonOptions[] | No | [] | Array of polygon configurations. See PolygonOptions | | circles | google.maps.CircleOptions[] | No | [] | Array of circle configurations. See CircleOptions | | rectangles | google.maps.RectangleOptions[] | No | [] | Array of rectangle configurations. See RectangleOptions | | height | string | No | "500px" | Height of the map container | | width | string | No | "500px" | Width of the map container | | libraries | string | No | "marker,geometry,drawing,places" | Comma-separated list of Google Maps libraries to load. See Libraries | | scriptLoadingTimeout | number | No | 5000 | Timeout in milliseconds for loading the Google Maps JavaScript API |

Events

The component emits the following events when Google Maps objects are created, providing access to the underlying API instances:

| Event | Payload Type | Description | |----------------------|---------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------| | map-created | google.maps.Map | Emitted when the map instance is created | | markers-created | google.maps.marker.AdvancedMarkerElement[] | Emitted when marker instances are created | | polylines-created | google.maps.Polyline[] | Emitted when polyline instances are created | | polygons-created | google.maps.Polygon[] | Emitted when polygon instances are created | | circles-created | google.maps.Circle[] | Emitted when circle instances are created | | rectangles-created | google.maps.Rectangle[] | Emitted when rectangle instances are created |

Event Usage Example

<script setup lang="ts">
import { GoogleMap } from "google-map-ts-vue3";

const handleMapCreated = (map: google.maps.Map) => {
  console.log("Map instance:", map);
};

const handleMarkersCreated = (markers: google.maps.marker.AdvancedMarkerElement[]) => {
  console.log("Marker instances:", markers);
};
</script>

<template>
  <GoogleMap
    apiKey="YOUR_GOOGLE_MAPS_API_KEY"
    :options="{ center: { lat: 35.1, lng: 135.1 }, zoom: 5, mapId: 'DEMO_MAP_ID' }"
    :markers="[{ position: { lat: 35.1, lng: 135.1 }, title: 'Marker' }]"
    @map-created="handleMapCreated"
    @markers-created="handleMarkersCreated"
  />
</template>

Important Notes

Map ID Requirement

The mapId property is required in options when using Advanced Markers (the default marker type). Create a Map ID in the Google Cloud Console.

TypeScript Support

This library includes full TypeScript type definitions from @types/google.maps, providing comprehensive type safety and IDE autocomplete for all Google Maps API features.

License

This project is licensed under the MIT License - see the LICENSE file for details.