I'm using a ajax plugin (Ajaxify Wordpress Site) for my Wordpress site and I've managed to get Google maps to work but I'm getting the error "You have included the Google Maps API multiple times on this page".
I've enqueued the Google Maps script in my functions file and included the following code in my js file:
var map;
function initialize() {
var mapOptions = {
zoom: 8,
center: new google.maps.LatLng(-34.397, 150.644)
};
map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
}
google.maps.event.addDomListener(window, 'load', initialize);
To get the Ajax plugin to reload the Google Maps script I added this code to the plugin js, which is where I think the problem is:
scriptNode = document.createElement('script');
contentNode.appendChild(scriptNode);
scriptNode.setAttribute('src', 'https://maps.googleapis.com/maps/api/js?key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' +
'&signed_in=true&callback=initialize');
scriptNode = document.createElement('script');
Any ideas?