mhirdes / go_maps_ext

Google Maps Extension for TYPO3
MIT License
21 stars 31 forks source link

goMapsExtController cached in goMapsExtControllerStorage, when goMapsExtLoaded is called. #107

Closed slavlee closed 1 year ago

slavlee commented 1 year ago

There is a chance that there is nothing inside the variable: goMapsExtControllerStorage, when the callback is executed.

In this case JS error occures due no return value check, when calling initialize() and no map is shown as well.

One possible workaround is to change the goMapsExtLoaded as follows:

window.goMapsExtLoaded = function() {
  const maps = document.querySelectorAll('.js-map');
  maps.forEach(function (el) {
    const goMapsExtController = getGoMapsExtControllerById(el.id);

    if (goMapsExtController) {
      goMapsExtController.initialize();
    }else {
      // if not search controller loaded, then retry 
      // after 250ms
      console.log("No controller found. We retry in 250ms");
      setTimeout(goMapsExtLoaded, 250);
    }
  });
}
SicorDev commented 1 year ago

Thank you very much for this wokaround, now our map shows up again!

mhirdes commented 1 year ago

Thanks for the workaround. The fix is online

riegeo commented 1 year ago

Thanks for this workaround. I had this Problem on every website with TYPO3 12. Uncaught (in promise) InvalidValueError: goMapsExtLoaded is not a function

Now the maps work again.