Code works excellent on browser but lacks on device?


#1

I wrote code for an app to track user location and display it using Google Maps. My code works perfectly in browsers (Safari,Firefox,Chrome) but doesn’t work at all on mobile (android). The google maps api doesn’t work and the navigation is unreliable. I’m a ionic newbie and wrote a fairly simple app to test it out. It has got ionic side menu template with some simple angjs controller.
Check it on Github https://github.com/Saumik/ionicgooglemaps
Any help on this would be appreciated :smile:


#2

I’ve checked your code and you have one simple mistake. You forgot to put closing </script> tag at the end of Google maps script (end of your index.html).
I haven’t tried it on the actual device, but on iOS simulator and that fixed the problem of both showing map and navigation.


#3

Hey dude, I’m sorry for the late response but the code still doesn’t work on android (tested on device) but works on the ios simulator.
Following the steps in this http://stackoverflow.com/questions/30723403/google-maps-on-ionic-framework-cordova-not-working-on-android-build works but these are not secure for production. Any idea on how to improve it.


#4

Have you checked the readme at:
https://github.com/apache/cordova-plugin-whitelist#cordova-plugin-whitelist ?

I guess you will have to play with Content Security Policy and find the solution that works for you.