poldixd/json-mapstyle-converter

Converts Google Maps JSON Style to Google Maps Static Maps Style

Installs: 107

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/poldixd/json-mapstyle-converter

0.1.0 2021-02-05 10:23 UTC

This package is auto-updated.

Last update: 2025-10-05 20:35:43 UTC


README

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