ionic-framework icon indicating copy to clipboard operation
ionic-framework copied to clipboard

Codepen Google Maps Example Fails on iOS

Open ccj242 opened this issue 10 years ago • 16 comments

Hi!

I was integrating the javascript google maps api into my ionic app and just couldn't get it to work when running on my iPhone. Everything worked perfect on android, when serving, and when simulating iOS. I thought I must be missing something until I tried the official codepen: Google Maps Example: Nightly and had the same results. Is anyone else experiencing this issue? I have an iPhone 6 plus 9.2.1.

Thanks for your help!

ccj242 avatar Mar 20 '16 09:03 ccj242

Hi , Here is a demo app for integrating google maps with IONIC. works fine with Android 4.1+ and iOS 7+ This might help !!!

abhaykumar1415 avatar Mar 21 '16 16:03 abhaykumar1415

Hey Abhay! Thanks so much for your response -- unfortunately I can't get your demo app working -- when I serve, I can only see a magnifying glass icon and get a sensor/api key warning. I'm sure I'm just doing something stupid!

ccj242 avatar Mar 21 '16 20:03 ccj242

Hello guys! Thanks for opening an issue with us! Are you getting any console errors?

jgw96 avatar Mar 21 '16 20:03 jgw96

this is related to issue #5712

jgw96 avatar Mar 21 '16 21:03 jgw96

Hey Justin — It’s the strangest thing. Everything from the Codepen example works perfectly when serving locally, when building to android and even when simulating iOS… no console errors, no problems.

When I build to iOS and run to a device through Xcode however, that’s when things break down, an Xcode doesn’t show any errors in its console.

I’m not sure if it’s related to the other issue as I’m not using the native plugin - per the codepen, I’m just using the javascript api.

Thanks!

On Mar 21, 2016, at 4:48 PM, Justin Willis [email protected] wrote:

Hello guys! Thanks for opening an issue with us! Are you getting any console errors?

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/driftyco/ionic/issues/5892#issuecomment-199474554

ccj242 avatar Mar 21 '16 21:03 ccj242

My friend, also an ionic developer, mentioned to me that he ran into this awhile back - maybe it's not advisable to use the javascript API and we should instead use the native plugin?

ccj242 avatar Mar 21 '16 21:03 ccj242

No problem at all! Do you happen to have an explicit height and width set on the element your rendering your map in? Also can you try installing this plugin https://github.com/mapsplugin/cordova-plugin-googlemaps, but still using the web api as this plugin will set up the permissions correctly for you. If this fixes the issue then i know exactly what is wrong.

jgw96 avatar Mar 21 '16 21:03 jgw96

Hey Justin - I wish I could tell you that fixed it, but no - unfortunately I’m still not able to get the codepen example to work. If I start a new ionic project from the pen, add the plugin and build for iOS, something breaks - although it seems to serve fine, simulate on iOS, and run on android.

Sorry for the trouble and thanks for your help!

On Mar 21, 2016, at 5:18 PM, Justin Willis [email protected] wrote:

No problem at all! Do you happen to have an explicit height and width set on the element your rendering your map in? Also can you try installing this plugin https://github.com/mapsplugin/cordova-plugin-googlemaps https://github.com/mapsplugin/cordova-plugin-googlemaps, but still using the web api as this plugin will set up the permissions correctly for you. If this fixes the issue then i know exactly what is wrong.

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/driftyco/ionic/issues/5892#issuecomment-199490744

ccj242 avatar Mar 22 '16 04:03 ccj242

Hi Christopher, Try ionic serve --lab

Here is a screenshot for the same. screen shot 2016-03-22 at 10 28 02 am

And it works fine on my android device as well.

abhaykumar1415 avatar Mar 22 '16 04:03 abhaykumar1415

So after some debugging work I suspect it might be a whitelisting issue… when building to an iOS device, angular doesn’t seem to be loaded at all (in the html I put {{1+2}} and it came back as literal). I’ll keep playing around and hopefully something get something working.

On Mar 21, 2016, at 5:18 PM, Justin Willis [email protected] wrote:

No problem at all! Do you happen to have an explicit height and width set on the element your rendering your map in? Also can you try installing this plugin https://github.com/mapsplugin/cordova-plugin-googlemaps https://github.com/mapsplugin/cordova-plugin-googlemaps, but still using the web api as this plugin will set up the permissions correctly for you. If this fixes the issue then i know exactly what is wrong.

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/driftyco/ionic/issues/5892#issuecomment-199490744

ccj242 avatar Mar 23 '16 03:03 ccj242

@ccj242. Sorry you are still running into this issue, I was for sure that my previous post was going to fix it for you. Are you testing on any other devices but your iPhone? And if so do you run into the same issue?

jgw96 avatar Mar 23 '16 14:03 jgw96

Yes I’ve been testing on an iPad and another iPhone 5S, same issue….

Ok, this is insane: when I run directly to the iPad/iPhone using “ionic run iOS --device -l -c” (I wanted to get an error log) it works!! I get a sensor not required warning (as I do on other devices) but I’m in awe of the irony that it works only when I can see a console.

This must mean the problem occurs when publishing from Xcode… is there a specific permissions or whitelist setting I might be missing or something? Something that would stop angular from loading properly?

On Mar 23, 2016, at 10:11 AM, Justin Willis [email protected] wrote:

@ccj242 https://github.com/ccj242. Sorry you are still running into this issue, I was for sure that my previous post was going to fix it for you. Are you testing on any other devices but your iPhone? And if so do you run into the same issue?

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/driftyco/ionic/issues/5892#issuecomment-200360005

ccj242 avatar Mar 24 '16 00:03 ccj242

@ccj242 Would you mind giving this another test? It seems that Google may have released an update to the google maps api that seems to have solved this issue for some people. Thanks!

jgw96 avatar Mar 28 '16 14:03 jgw96

Hey Justin,

Please excuse me - I actually was able to fix my issue — I meant to repost::

By adding this to config.xml:

and by adding http:// to the beginning of where the maps API is loaded in index.html I was able to get it working.

Thanks for all your help!

On Mar 28, 2016, at 10:57 AM, Justin Willis [email protected] wrote:

@ccj242 https://github.com/ccj242 Would you mind giving this another test? It seems that Google may have released an update to the google maps api that seems to have solved this issue for some people. Thanks!

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/driftyco/ionic/issues/5892#issuecomment-202426988

ccj242 avatar Mar 28 '16 23:03 ccj242

@ccj242 Awesome! Im glad your issue is resolved. Thanks for using Ionic!

jgw96 avatar Mar 29 '16 00:03 jgw96

Please, no thanks necessary. Ionic is incredible.

On Mar 28, 2016, at 8:45 PM, Justin Willis [email protected] wrote:

@ccj242 https://github.com/ccj242 Awesome! Im glad your issue is resolved. Thanks for using Ionic!

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/driftyco/ionic/issues/5892#issuecomment-202647265

ccj242 avatar Mar 29 '16 04:03 ccj242