Skip to content

jaydenseric/google-static-maps-styler-query

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

google-static-maps-styler-query

Converts a Google Maps styler array to a Google Static Maps styler URL query string.

Installation

For Node.js, to install google-static-maps-styler-query with npm, run:

npm install google-static-maps-styler-query

For browsers, an example import map:

{
  "imports": {
    "google-static-maps-styler-query": "https://unpkg.com/google-static-maps-styler-query@6.0.0/googleStaticMapsStylerQuery.mjs"
  }
}

Then, import and use the function googleStaticMapsStylerQuery.

Examples

How to create a styled static map URL:

import googleStaticMapsStylerQuery from "google-static-maps-styler-query";

const styles = [{ elementType: "labels", stylers: [{ visibility: "off" }] }];
const stylerQuery = googleStaticMapsStylerQuery(styles);
const googleStaticMapSrc = `https://maps.googleapis.com/maps/api/staticmap?center=Australia&size=250x200${stylerQuery}`;

Requirements

Supported runtime environments:

Projects must configure TypeScript to use types from the ECMAScript modules that have a // @ts-check comment:

Exports

The npm package google-static-maps-styler-query features optimal JavaScript module design. These ECMAScript modules are exported via the package.json field exports: