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

google-maps-image-api

v1.0.3

Published

This is an easy way to consume the Google Maps Image API to render static maps or street views

Downloads

30

Readme

#google-maps-image-api ##google-maps-image-api~BASE_URL Allows you to easily consume the Google Maps Image API.

Google Maps Image API allows you to get static images of a 2d map or streetview.

This module will return a promise or you can call it via a callback.

The callback will return an error (if an error occured) and and HTMLImageElement.

Options passed in correlate to properties you can pass to Google Maps Image API.

Here are parameter's you can pass through opts to render a static map:

{
	//// REQUIRED ////
	type: 'staticmap', // This value is required if you want to render a static map
	
	center: '40.714728,-73.998672', // This will be the center of your image. 
									// It can also be a street address
 

	
	//// OPTIONAL ////
	key: 'your api key', // Your Google API Key

	zoom: 14, // This will be how zoomed in the map will be. 0 is where you 
 		  // can see the entire world, 21 is where you see streets. 14 is default
 		  
	size: '320x240', // This is the pixel size of your map. Default 320x240
	
	scale: 1, // This property is meant for rendering maps with high pixel 
			  // resolutions eg. iphone 4+ is retina this value should be set to 2

	format: 'JPEG', // Possible valuse 'PNG', 'GIF', 'JPEG',

	maptype: 'roadmap', // What type of map you want to render 
						// 'roadmap', 'satellite', 'hybrid', and 'terrain'

	language: 'en', // Language in which you want the map to be rendered

 region: 'us', // Country code in: ccTLD. defines the appropriate borders to display, 
 			  // based on geo-political sensitivities

	markers: 'color:blue|label:S|11211|11206|11222',
	// Add markers to the map. For docs:
	// https://developers.google.com/maps/documentation/staticmaps/index#Markers

	path: 'color:0x0000ff|weight:5|40.737102,-73.990318|40.749825,-73.987963',
	// Add a path to the map. A path can be filled or just a line. For docs:
	// https://developers.google.com/maps/documentation/staticmaps/index#Paths

	visible: 'Toronto', // you can specify locations that should be visible on the 
				 		// rendered map. This can be either lat,long or a location name

	style: 'feature:administrative|element:labels|weight:3.9|visibility:on|inverse_lightness:true', 
	// this property will change how features are rendered eg. roads, parks, etc.
	// For docs:
	// https://developers.google.com/maps/documentation/staticmaps/index#StyledMaps
}

Here are the parameters you'd pass in to render a streetview:

{
	//// REQUIRED ////
	type: 'streetview',
	location: 'Toronto', // Location name or long,lat. 
						 // if you ommit location you must define pano
	pano: 'pano id', // An id for a specific panorama. If you omit 
					 // you must define a location

	//// OPTIONAL ////
	key: 'your api key', // Your Google API Key
	
	size: '320x240', // The size of your render in pixels

	heading: 45, // This is the compass heading which the camera is pointing at
				 // between 0 and 360. 0 == North

	fov: 90, // field of view expressed in degrees. (angle which determines how much you see)
			 // default is 90

	pitch: 0, // up down angle the camera is pointing at. 90 is straight up and -90 is straight down
}

Params

  • opts Object - These are options that will be used to render streetview and map images
  • callback function - Optionally you can use a callback over a promise. See above for details

Scope: inner member of google-maps-image-api
Returns: Promise - A promise is returned which will return an HTMLImageElement