gmaps-apistyle-encoder

0.0.1 • Public • Published

GMaps API Style Encoder

Synopsis

Small utility to encode your styles when requesting map tiles from Google

Turned into an npm package by myself but based on posts by Dr.Molle and Manuel Otto on Stack Overflow.

Usage

Create your own map styling JSON at https://mapstyle.withgoogle.com/, encode it and add it to your tiles URL with the apistyle parameter.

import encodeMapStyles from 'gmaps-apistyle-encoder';

styles = [
  {
    "featureType": "administrative.land_parcel",
    "stylers": [{ "visibility": "off" }]
  }
];

const apistyles = encodeMapStyles(styles); // Returns s.t%3A21%7Cp.v%3Aoff

const url = 'http://mt0.google.com/vt/lyrs=m&hl=en&x={x}&y={y}&z={z}&s=Ga&apistyle=' + apistyles

Warning: It's possible that newer featureTypes or elementTypes are unknown to the encoder. Please open an issue if you see a mismatch.

Installation

npm i -S google-maps-apistyle-encoder

Readme

Keywords

none

Package Sidebar

Install

npm i gmaps-apistyle-encoder

Weekly Downloads

1

Version

0.0.1

License

ISC

Last publish

Collaborators

  • julienben