The script will look for a <div>
with class map-style
nested as a direct child of the main map <div>
.
The text content of the div is expected to be properly formatted JSON and is parsed on page load.
This example uses the Light Dream preset found on Snazzy Maps. The text was copied directly from the code box on Snazzy Maps and pasted as the only text inside
the div.map-style
. If the text is valid JSON, the style will work as expected.
<div data-maps-api-key="INSERT_YOUR_GOOGLE_MAPS_API_KEY_HERE" data-address="389 Greenpoint Ave, Crown Heights, Brooklyn New York" data-map-zoom="14">
<div class="map-marker" data-address="389 Greenpoint Ave, Crown Heights, Brooklyn, New York">
</div>
<div class="map-style">
[
{
"featureType": "landscape",
"stylers": [
{
"hue": "#FFBB00"
},
{
"saturation": 43.400000000000006
},
{
"lightness": 37.599999999999994
},
{
"gamma": 1
}
]
},
{
"featureType": "road.highway",
"stylers": [
{
"hue": "#FFC200"
},
{
"saturation": -61.8
},
{
"lightness": 45.599999999999994
},
{
"gamma": 1
}
]
},
{
"featureType": "road.arterial",
"stylers": [
{
"hue": "#FF0300"
},
{
"saturation": -100
},
{
"lightness": 51.19999999999999
},
{
"gamma": 1
}
]
},
{
"featureType": "road.local",
"stylers": [
{
"hue": "#FF0300"
},
{
"saturation": -100
},
{
"lightness": 52
},
{
"gamma": 1
}
]
},
{
"featureType": "water",
"stylers": [
{
"hue": "#0078FF"
},
{
"saturation": -13.200000000000003
},
{
"lightness": 2.4000000000000057
},
{
"gamma": 1
}
]
},
{
"featureType": "poi",
"stylers": [
{
"hue": "#00FF6A"
},
{
"saturation": -1.0989010989011234
},
{
"lightness": 11.200000000000017
},
{
"gamma": 1
}
]
}
]
</div>
</div>