Results 1 to 5 of 5

Thread: Catching Google Maps error when starting app while offline

  1. #1
    Sencha User
    Join Date
    Nov 2011
    Posts
    44
    Vote Rating
    0
      0  

    Default Catching Google Maps error when starting app while offline

    Hello everyone,

    I have integrated Google Maps Api 3 in my app but when I'm offline (having no internet connection) and start the app the following error is thrown:
    Code:
    file:///android_asset/www/app/views/map/MapView.js: Line 144 : Uncaught ReferenceError: google is not defined
    o   04-13 21:48:12.234: E/Web Console(1369): Uncaught ReferenceError: google is not defined at file:///android_asset/www/app/views/map/MapView.js:144
    Actually I just wanna catch this error so that the whole app doenst stop. But I'm not sure how, since the Google Maps Code is already used in my index.html file:
    <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>

    Any tips or advices how/where to wrap an try&catch statement?

    Thanks in advance,
    Florian

  2. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,551
    Answers
    3931
    Vote Rating
    1271
      0  

    Default

    You can do something like

    Code:
    google && google.something.Foo
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

  3. #3
    Sencha User
    Join Date
    May 2012
    Location
    rome
    Posts
    70
    Answers
    3
    Vote Rating
    0
      0  

    Default

    this post interests me too

    can you please give some more information about the code you posted

    I cannot handle any code when google.maps is not loaded (due to missing connection); no way to catch the rising error

    another solution could be to 'require' the view only if the google.maps is defined, but I'm not sure it is possible someway!

    thank you for any additional suggestion, alex

  4. #4
    Sencha User
    Join Date
    Jul 2013
    Posts
    99
    Answers
    7
    Vote Rating
    10
      0  

    Default

    Hi there

    Further on this topic I would like to find out how a Phonegap-wrapped app will behave with no internet connection.Is there a way of loading & caching the Google Maps library so that (a) you don't get the error and (b) later at some point when you are connected, maps will load. I am unclear of the implications of an app loading when offline & coming online at a later stage - whether map-related content will be available then.If one is using Google Maps in a Phonegap-wrapped app how does one handle the loading/online/offline switching + map integration - ie:- app loads, is not online- user tries to access map-related content- after a period of time app goes online- user tries to access map-related content

    Thanks
    -tt88

  5. #5
    Sencha User
    Join Date
    Jul 2013
    Posts
    99
    Answers
    7
    Vote Rating
    10
      0  

    Default

    For anyone experiencing the same issue, here are 2 useful links.
    I managed to get it to work with loading the js asynchronously when the user changes to an online state.
    http://stackoverflow.com/questions/10251329/sencha-touch-google-maps-with-an-online-offline-app-possible-to-load-map-when
    http://stackoverflow.com/questions/1...-load-map-when

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •