poldixd / json-mapstyle-converter
Converts Google Maps JSON Style to Google Maps Static Maps Style
0.1.0
2021-02-05 10:23 UTC
Requires
- php: ^7.2|^8.0
Requires (Dev)
- phpunit/phpunit: ^9.5
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