not very proficient at JS, nor do I really understand what promises are. But I will do my best to describe the issue.
On this location page, I have some inline JS to output a Google Map. Pretty straight forward, and works fine until the JS is concatenated by a plugin.
So the weird part is when this error is thrown, the code below isn't output at all. If I remove concatenation it works fine. This may be an issue with the Wordpress plugin (WP Rocket), and not a javascript specific issue. I'm not sure, hoping for any tips.
The Code:
<script>function initMap() {
var map = new google.maps.Map(document.getElementById('map'), {
center: { lat: 41.559345, lng: -88.133326 },
zoom: 16
});
//setMarkers(map);
}
function setMarkers(map) {
marker = new google.maps.Marker({
position: {lat: 41.559345, lng: -88.133326},
map: map,
title: "Crest Hill",
//icon: customMarker
});
marker.addListener('click', function() {
map.setZoom(16);
map.setCenter(marker.getPosition());
});
}
</script>
The Error:
Uncaught (in promise) Mc {message: "initMap is not a function", name: "InvalidValueError", stack: "Error↵ at new Mc (https://maps.googleapis.com/m…QpokXsxbUPOzocygFOXXXXX&callback=initMap:123:96"}