I've got a site that navigates and reloads page information using HTML5 history API. This sends an AJAX call which retrieves the relevant page information. On my 'contact' page I have the google maps api script. If the page is loaded by accessing the URL it works fine. Google loads in the maps API and includes it before my closing body tag.
If I navigate away from the page (using the history API to remove and add content) and then return to the contact page (again through the history API) a second call is made to the (already included) maps API and it doubles it up. This causes the warning message in the console.
I've tried removing the Google Maps script that's added before the closing body tag before the new content is loaded but as the script has been parsed all the relevant functions for the map remains in the browser memory.
So I guess my question is, 'Is there any way to unload all of the google maps JS as I make my AJAX requests for page content?'.
The console message is as follows:
Warning: you have included the Google Maps API multiple times on this page. This may cause unexpected errors.