Redirect if google not accessible in visualization

OndrejH

Member
Hello,
Do you anyone have any hint how to redirect the page from googla map visualization in the case user does not have access to google servers?
Possibly right from Menu (map visualization) ->
1) google server accessible ... OK
2) google server not accessible ... redirect
Thank you,
Ondrej
 
Hmmm.

Actually not as easy as it might seem.

We load the Google maps API with a "callback", meaning we fire off the request to the map API URL, and once it has loaded, the Google code calls our function, and we initialize the viz. So it happens asyncronously, and if the maps API doesn't load, then our viz init simply doesn't get called. We don't get a callback to say "it never loaded" ... the callback just doesn't happen.

About the only way I can think of would be some custom JS, running on 'load', with a timer, than waits (say) 2 seconds and then check to see if the google object is ready.

Putting this in ./components/com_fabrik/js/viz_X.js (where X is your numeric viz ID) might work ...

Code:
var checkMapsLoaded = function() {
   if (typeof google !== 'object' && typeof google.maps !== 'object') {
     alert('No goog!');
     window.location('http://your.site/whatever');
   }
}
window.onload = function() {
  setTimeout(checkMapsLoaded, 2000);
}

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top