1. #1
    Sencha User
    Join Date
    Nov 2011
    Posts
    44
    Vote Rating
    0
    Tamuha is on a distinguished road

      0  

    Default Unanswered: Catching Google Maps error when starting app while offline

    Unanswered: 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 - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,522
    Answers
    3447
    Vote Rating
    814
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    You can do something like

    Code:
    google && google.something.Foo
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    May 2012
    Location
    rome
    Posts
    67
    Answers
    3
    Vote Rating
    0
    alexdran is on a distinguished road

      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
    tt88 will become famous soon enough

      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
    tt88 will become famous soon enough

      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