arvgta / ajaxify

Ajaxify - The Ajax Plugin
https://4nf.org/
274 stars 124 forks source link

Google Maps support #152

Closed arvgta closed 5 years ago

arvgta commented 6 years ago

In the last while, I have been trying to add Google Maps support to Ajaxify.

Here is the salient HTML I'm trying out now, which should be placed on the target page (only):

<div id="map"></div>
<script>function initMap() {  
    var map = new google.maps.Map(document.getElementById('map'), {
    zoom: 15,
    center: {lat: 48.1351253, lng: 11.581980499999986}
});}
</script>
<script async defer src="https://maps.googleapis.com/maps/api/js?key=myKey&#038;callback=initMap"></script>
<script>typeof(google) !== "undefined" && initMap();</script>

(the last line I have made up myself, for the approach to work with Ajaxify)

You can see it working without issues on these two sites:

However, it fails on this site:

...with the following error message in the console: ...initMap is not a function...

Any ideas, why the third demo doesn't work?

All three demos share the above code. In all three cases the div id="map" is dimensioned generously in the respective stylesheets to reserve space for the map. The only striking difference to Demo 3 is that some scripts, including Ajaxify are loaded later. It is a Bootstrap + Ajaxify site with extremely clean HTML, whereas the first two demos are Wordpress + Ajaxify sites.

arvgta commented 5 years ago

I hope Demo 3 fails due to the architecture of the site only.

Further documention may be placed here.

Closing... Please re-open, when in doubts.