InAppBrowser geolocation. Problem with Google Maps

661 views
Skip to first unread message

Damian Hetman

unread,
Jun 1, 2015, 12:36:12 PM6/1/15
to phon...@googlegroups.com
Hi, I have a problem with my simple-stupid app. Instead of doing app in phonegap I just have done:
window.open('http://mywebsite.com', '_self', 'location=no', 'closebuttoncaption=back');
And this is only thing in my PhoneGap app.

In mywebsite.com I have script that locate my device (it's standard gelocation integrated with Google Maps). But problem is that if I turn off my GPS I should have message like "We can't locate you" but there is no message. This message works when I go to mywebsite.com from normal webbrowser (works on computer and phone) but it doesn't work in PhoneGap. If I turn on my GPS on my device it shows me my coordinates... I hope you understand my problem. Can you help me?

Jesse Monroy

unread,
Jun 1, 2015, 11:05:56 PM6/1/15
to phon...@googlegroups.com
@Damian,
I think mharr or Kerri can verify, but I'm next to positive you are opening NEW instance of Phonegap and NOT an inherited webpage. This is (i think) security related.

The other thing, more pertinent, is that Phonegap is NOT a webbrowser, so I does NOT behave as a normal webbrowser. On Android, we are using Webview, and it is essentially a stripped down webbrowser. So, I'm not surprised you are not get the results.

From the Reference Page
A View that displays web pages. This class is the basis upon which you can roll your own web browser or simply display some online content within your Activity. It uses the WebKit rendering engine to display web pages and includes methods to navigate forward and backward through a history, zoom in and out, perform text searches and more.
 

Basic usage

By default, a WebView provides no browser-like widgets, does not enable JavaScript and web page errors are ignored. If your goal is only to display some HTML as a part of your UI, this is probably fine; the user won't need to interact with the web page beyond reading it, and the web page won't need to interact with the user. If you actually want a full-blown web browser, then you probably want to invoke the Browser application with a URL Intent rather than show it with a WebView. For example:

 

Jesse

jcesarmobile

unread,
Jun 2, 2015, 2:18:40 AM6/2/15
to phon...@googlegroups.com
What about posting your code?

You should have something like this:

navigator.geolocation.getCurrentPosition(success, error);

on the error function you should show the error message

Damian Hetman

unread,
Jun 2, 2015, 4:54:17 AM6/2/15
to phon...@googlegroups.com
I have that code but I have it on my website, not in PhoneGap app. It's javascript code integrated with Google Maps script.

jcesarmobile

unread,
Jun 2, 2015, 5:59:36 AM6/2/15
to phon...@googlegroups.com
Yeah, that's the html5 geolocation code to get the current position.
There should not be any difference on the code as phonegap uses the html5 geolocation too.

The browser might handle the case that the GPS is turned off by you, but the error callback should be called any way, it doesn't matter if you load it on a browser or in a webview (inAppBrowser)

Kerri Shotts

unread,
Jun 2, 2015, 11:32:54 AM6/2/15
to phon...@googlegroups.com, deh...@gmail.com
Which browser (on the device)? Chrome? Firefox? etc? 

Test with an AOSP browser that uses the same webview that PG uses and see if you encounter the same issue. 
Reply all
Reply to author
Forward
0 new messages