To display a Google Map on a Webflow CMS template page, dynamically pulling an address from a Collection field while applying a Snazzy Maps theme, follow these steps:
<div id="map" style="width: 100%; height: 400px;"></div><script> function initMap() { var geocoder = new google.maps.Geocoder(); var address = "{{wf {"path":"location-address","type":"PlainText"} }}"; geocoder.geocode({ 'address': address }, function(results, status) { if (status === 'OK') { var map = new google.maps.Map(document.getElementById('map'), { zoom: 14, center: results[0].geometry.location, styles: snazzyMapStyles }); new google.maps.Marker({ map: map, position: results[0].geometry.location }); } }); } var snazzyMapStyles = [ /* INSERT YOUR SNAZZY MAP JSON STYLE HERE */ ];</script><script async defer src="https://maps.googleapis.com/maps/api/js?key=YOUR_GOOGLE_MAPS_API_KEY&callback=initMap"></script>
snazzyMapStyles = [ /* INSERT YOUR SNAZZY MAP JSON STYLE HERE */ ];
with the copied JSON.This method uses a Google Maps Embed with Webflow CMS fields, geocodes addresses dynamically, and styles the map with Snazzy Maps JSON. Ensure your Google Maps API key is active and your CMS contains properly formatted addresses.