Reputation: 23
This is my first post on Stackoverflow. I will describe my problem:
It is about an Phonegap Build-application in HTML and Javascript. I have two files:
"index.html" see source on http://pastebin.com/RCQruFkE
"config.xml" see source on http://pastebin.com/1xCvvHL1
We have two Android-devices:
1) Samsung Galaxy Y (Android OS 2.3.6)
2) Samsung Galaxy S2 (Android OS 4.1.2)
Also on my simulator, Android OS 4.3, it doesn't work. You only see: "Finding geolocation...". On my Samsung Galaxy Y (2.3.6) you will succesfully see the geolocation (latitude and longitude and some other information).
I have also tried to use "cordova.js" with cordova 3.0.0 in it (JS) and without the file, makes no sense.
Does anyone have the same problem? It has been started last Thursday in the evening (then it worked) and Friday morning it didn't work anymore. Same APK!
Upvotes: 1
Views: 901
Reputation: 4335
Alternatively you can use http://ip-api.com/json . They provide latitude, longitude, city, country etc
jQuery example:
$.getJSON("http://ip-api.com/json",function(data){
var lat = data.lat;
});
Their json output:
{"as":"AS10199 Tata Communications Ltd","city":"Pune","country":"India","countryCode":"IN","isp":"Tata Communications","lat":18.5333,"lon":73.8667,"org":"Tata Communications","query":"115.117.217.243","region":"MH","regionName":"Maharashtra","status":"success","timezone":"Asia/Kolkata","zip":"411001"}
It's that simple.
Upvotes: 1
Reputation: 38
Try adding "enableHighAccuracy" and "timeout", i have seen this issue in some android devices where a timeout should be set to allow for geolocation services to work.
var options = { enableHighAccuracy: true, timeout: 5000, };
Upvotes: 0
Reputation: 3297
You have referenced cordova.js but it should be phonegap.js when using PhoneGap Build
<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
Should Be
<script src="phonegap.js"></script>
EDIT:
Here is a link to the official PGB boilerplate:
https://github.com/phonegap/phonegap-start/tree/master/www
See the contents of the index.html file.
Upvotes: 0