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

static-google-map-ts

v0.0.9

Published

A strongly typed URL builder for Google Maps Static.

Downloads

1,172

Readme

static-google-map-ts

A strongly typed URL builder for Google Maps Static.

Overview

This is designed to be [mostly] compatible with the static-google-map package, but is written entirely in TypeScript. To reduce dependencies, it doesn't have implement asynchronous asyncStaticMapUrl method, however it supports Encoded Polyline Algorithm Format. See Paths

Installation

npm install static-google-map-ts

Basic Usage

import { staticMapUrl, GoogleMapImage } from "static-google-map-ts";

const options: GoogleMapImage = {
  key: "Your API Key",
  size: {width: 600, height: 600}, // Also accepts a string, eg. "600x600"
  zoom: 8,
  markers: {
    location: "TipsTrade,GBR", // Also accepts a google.maps.LatLng or google.maps.LatLngLiteral
},
const url = staticMapUrl(options);

Reference

Documentation isn't unavailable yet, however the properties usage is described in the Maps Static API Documentation. JSDoc comments are also provided for all types and interfaces.

Parameter types

Most properties should be self explanatory, however some are Union types:

  • AnchorType - Can be any of the following
    • a string containing an anchor ("left", "top", etc)
    • a string containing an x,y point ("16, 21")
    • an Anchor interface {x:16, y:21}
  • ColorType - Can be any of the following
    • a 24-bit RGB ("0xaabbcc") or 32-bit RGBA ("0xaabbccff") hex string
    • a number
  • LocationType - Can be any of the following
    • a string cotnaining a place
    • a string containing a position, ("51.75, -1")
    • a LatLng interface, as used by the Google Maps API
    • a LatLngLiteral interface, as used by the Google Maps API
  • SizeType - Can be any of the following
    • a string containing a size ("600x400")
    • a Size interface {width: 600, height: 400}

Paths

The Path interface accepts both an array of LocationType objects or a string containing Encoded Polyline Algorithm Format.

Usage alongside the Google Directions API

new google.maps.DirectionsService().route({
  origin: "Dublin",
  destination: "Limerick",
  travelMode: google.maps.TravelMode.DRIVING,
}, (result, status) => {
  if (!result || status !== google.maps.DirectionsStatus.OK) {
    return;
  }

  // The overview_polyline contains a simplified route path and is already encoded
  const points = result.routes[0].overview_polyline;

  const url = staticMapUrl({
    key: "Your API Key",
    size: {width: 600, height: 400},
    paths: {
      points,
    },
  })

  console.log(url);
});