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
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