Giter Site home page Giter Site logo

gmaps-apistyle-encoder's Introduction

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": "road.arterial",
    "elementType": "labels",
    "stylers": [{"visibility": "off"}]
  },
  {
    "featureType": "road.highway",
    "elementType": "labels",
    "stylers": [{"visibility": "off"}]
  },
  {
    "featureType": "road.local",
    "stylers": [{"visibility": "off"}]
  }
];

const apistyles = encodeMapStyles(styles); // Returns "s.t%3A50%7Cs.e%3Al%7Cp.v%3Aoff%2Cs.t%3A49%7Cs.e%3Al%7Cp.v%3Aoff%2Cs.t%3A51%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

gmaps-apistyle-encoder's People

Contributors

julienben avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Forkers

josegoncalves

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.