问题
I have coded a small geolocation application using HTML and Javascript. I am using Phonegap to build it.
Geolocation worked fine until adding the config.xml file. I have added all the correct permissions for Phonegap (3.1.0).
Here's the relevant bits of code:
<!--
Enable individual API permissions here.
The "device" permission is required for the 'deviceready' event.
-->
<feature name="http://api.phonegap.com/1.0/device" />
<feature name="http://api.phonegap.com/1.0/geolocation"/>
<preference name="permissions" value="INTERNET" />
Here's the full code, if interested: https://github.com/wolffe/LifeMap, and here's the app: https://build.phonegap.com/apps/725755/builds
EDIT #1: It works in browser.
EDIT #2: I have removed the Cordova plugin permission.
EDIT #3: I have removed the config.xml file and it now works again. Using Phonegap Build 3.1.0.
回答1:
I don't think that the Cordova geolocation plugin works very well - the developers agreed to deprecate the geolocation plugin pretty recently because the Web Geolocation provided by the browser works as well or better in some cases.
I think you should remove the geolocation plugin from your project. You should be able to keep all of your JavaScript the same since I'm pretty sure it's the same API. I'm not sure about the permissions or not, but since it's Web GPS I'd think you don't have to include special permissions.
来源:https://stackoverflow.com/questions/21258762/geolocation-not-working-with-phonegap-build-after-adding-config-xml