我是在PhoneGap Build上開發的新手。在測試一些基本的應用程序功能時,我在Iphone 6/IOS 10/PhoneGap Build 6.3.0上執行簡單的地理位置請求時遇到超時問題。PhoneGap Build 6.3.0地理位置getCurrentPosition IOS緩慢
重新安裝應用程序後,我啓動它並通過onclick - > geolocation()啓動地理位置。
只有當我將應用程序置於後臺時,我纔會收到IOS請求以允許位置請求(應該在我首次在前臺執行onclick - > geolocation時出現)。
有時我會在很長一段時間後得到一個地理定位結果,有時候不會。我已經嘗試了三種PositionOptions上的所有可能組合。
當我詢問Google地圖應用程序時,它立即向我顯示位置。
任何想法我做錯了什麼?
謝謝你,金
function do_geolocation(){
\t alert('do geoloc');
\t navigator.geolocation.getCurrentPosition(geo_onSuccess, geo_onError, {maximumAge:120000, enableHighAccuracy:false});
}
onclick=do_geolocation();
function geo_onSuccess(position){
\t alert('Latitude: ' + position.coords.latitude + '\n' +
'Longitude: ' + position.coords.longitude + '\n' +
'Altitude: ' + position.coords.altitude + '\n' +
'Accuracy: ' + position.coords.accuracy + '\n' +
'Altitude Accuracy: ' + position.coords.altitudeAccuracy + '\n' +
'Heading: ' + position.coords.heading + '\n' +
'Speed: ' + position.coords.speed + '\n' +
'Timestamp: ' + position.timestamp + '\n');
\t var arr = new Array();
\t arr['lat'] = position.coords.latitude;
\t arr['lng'] = position.coords.longitude;
\t var x = new Date();var cb = x.getTime();
\t
}
function geo_onError(position){
\t
\t alert('code: '+error.code+'\nmessage: '+error.message+'\n');
\t return false;
}
<?xml version="1.0" encoding="UTF-8" ?>
<widget xmlns = "http://www.w3.org/ns/widgets"
xmlns:gap = "http://phonegap.com/ns/1.0"
id = "de.vvvvvv.secapp"
versionCode = "10"
version = "1.0.0" >
<!-- versionCode is optional and Android only -->
<name>vvvvvvv</name>
<description>
vvvvvvvvvvvv
</description>
<author href="http://vvvvvvv.de" email="[email protected]">
Kim
</author>
<plugin name="cordova-plugin-geolocation" spec="2.4.1" />
<plugin name="cordova-plugin-whitelist" spec="1.3.1" />
<access origin="*"/>
<allow-intent href="http://*/*"/>
<allow-intent href="https://*/*"/>
<preference name="orientation" value="portrait" />
<!-- https://makeappicon.com/ios10icon -->
<icon src="res/icons/ios/[email protected]" platform="ios" width="20" height="20" />
<icon src="res/icons/ios/[email protected]" platform="ios" width="40" height="40" />
...
您好戴夫,非常感謝您的詳細建議!我沒有認出你的快速答案。我已經按照建議更改了Content-Security-Policy,現在它正在工作。現在將仔細查看安全策略設置選項。 –