I am writing a mobile hybrid application using require.js as my download platform. I have a problem with loading errors. What I'm trying to do is install a backup solution when the device is disconnected and I cannot load the google maps script API that I need to display the map on the screen. All I get is
Uncaught Error: Load timeout for modules: async!http://maps.googleapis.com/maps/api/js?sensor=true
but I cannot catch this error and provide an alternative implementation. Here is my gmaps module definition
define('gmaps', ['async!http://maps.googleapis.com/maps/api/js?sensor=true'],function(){ return window.google.maps; });
What can I do?
EDIT
I managed to find a possible solution thanks to your help. I need to configure such settings
require.config({ paths: { gmaps: ['http://maps.googleapis.com/maps/api/js?sensor=true', 'lib/dummymaps'] } }
dummymaps is just a simple module:
define({ dummy: true });
Then in my โparentโ module I do:
define(["gmaps"],function(gmaps){ ... if(typeof gmaps.dummy != 'undefined' && gmaps.dummy == true){
Do you think this is a good solution?
EDIT 2:
Forgive me, it does not work with this code. It always returns to an alternative implementation, because gmaps needs to use the async plugin to fully load, and I cannot get it to work with the plugin.
source share