poldixd / json-mapstyle-converter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

poldixd/json-mapstyle-converter

Converts JSON Style Schemes for Google Maps to Styles for Google Static Maps.

From this:

[
  {
    "elementType": "geometry",
    "stylers": [
      {
        "color": "#212121"
      }
    ]
  },
  {
    "elementType": "labels.icon",
    "stylers": [
      {
        "visibility": "off"
      }
    ]
  }
]

To this:

&style=element:geometry|color:0x212121&style=element:labels.icon|visibility:off

You can use JSON Style Schemes from snazzymaps.com or mapstyle.withgoogle.com.

I converted this JavaScript Tool to a PHP Class.

Usage

$converter = new poldixd\JsonMapstyleConverter\JsonMapstyleConverter();

echo $converter->convert('[{"elementType": "geometry", "stylers": [ { "color": "#212121"}]},{"elementType": "labels.icon","stylers": [ {"visibility": "off"}]}]');

// &style=element:geometry|color:0x212121&style=element:labels.icon|visibility:off

About

License:MIT License


Languages

Language:PHP 100.0%