我正在做一個簡單的PhoneGap應用程序,它獲取用戶的位置。安裝不工作在Android - PhoneGap Build
用於我的生成的代碼是從地圖documentation
下面的例子是我的XML代碼:
<content src="index.html" />
<preference name="DisallowOverscroll" value="true" />
<preference name="android-minSdkVersion" value="14" />
<preference name="StatusBarOverlaysWebView" value="false" />
<preference name="StatusBarBackgroundColor" value="#ee6e73" />
<preference name="StatusBarStyle" value="blacktranslucent" />
<preference name="orientation" value="portrait" />
<plugin name="cordova-plugin-statusbar" source="npm" spec="~2.1.3" />
<plugin name="cordova-plugin-geolocation" source="npm" />
<plugin name="org.apache.cordova.globalization" source="npm" />
<plugin name="org.apache.cordova.geolocation" source="npm" />
<plugin name="cordova-plugin-console" source="npm" spec="~1.0.3" />
<plugin name="cordova-plugin-dialogs" source="npm" spec="~1.2.1" />
<plugin name="cordova-plugin-whitelist" source="npm" spec="~1.2.1" />
<feature name="Geolocation">
<param name="android-package" value="org.apache.cordova.geolocation.GeoBroker" />
</feature>
<allow-navigation href="*" />
<access origin="*" launch-external="yes" />
<access origin="*://*.googleapis.com/*" subdomains="true" />
<access origin="*://*.gstatic.com/*" subdomains="true" />
<access origin="*://*.google.com/*" subdomains="true" />
<access origin="*://*.googleusercontent.com/*" subdomains="true" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
<allow-intent href="market:*" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
而應用程序完美的作品上的瀏覽器,Android版本不加載位置。
進一步注意到maps.gstatic.com和mts.googleapis.com不從應用程序加載,都裝載在瀏覽器中,其隨後導致提供位置預先
感謝。
UPDATE 1:
,以免混淆,我已經使用由PhoneGap的桌面應用程序生成的默認config.xml中,仍然不能獲得的位置。
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.phonegap.helloworld" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0">
<name>new</name>
<description>
Hello World sample application that responds to the deviceready event.
</description>
<author email="[email protected]" href="http://phonegap.com">
PhoneGap Team
</author>
<content src="index.html" />
<preference name="DisallowOverscroll" value="true" />
<preference name="android-minSdkVersion" value="14" />
<plugin name="cordova-plugin-battery-status" source="npm" spec="~1.1.1" />
<plugin name="cordova-plugin-camera" source="npm" spec="~2.1.1" />
<plugin name="cordova-plugin-media-capture" source="npm" spec="~1.2.0" />
<plugin name="cordova-plugin-console" source="npm" spec="~1.0.2" />
<plugin name="cordova-plugin-contacts" source="npm" spec="~2.0.1" />
<plugin name="cordova-plugin-device" source="npm" spec="~1.1.1" />
<plugin name="cordova-plugin-device-motion" source="npm" spec="~1.2.0" />
<plugin name="cordova-plugin-device-orientation" source="npm" spec="~1.0.2" />
<plugin name="cordova-plugin-dialogs" source="npm" spec="~1.2.0" />
<plugin name="cordova-plugin-file" source="npm" spec="~4.1.1" />
<plugin name="cordova-plugin-file-transfer" source="npm" spec="~1.5.0" />
<plugin name="cordova-plugin-geolocation" source="npm" spec="~2.1.0" />
<plugin name="cordova-plugin-globalization" source="npm" spec="~1.0.3" />
<plugin name="cordova-plugin-inappbrowser" source="npm" spec="~1.3.0" />
<plugin name="cordova-plugin-media" source="npm" spec="~2.2.0" />
<plugin name="cordova-plugin-network-information" source="npm" spec="~1.2.0" />
<plugin name="cordova-plugin-splashscreen" source="npm" spec="~3.2.1" />
<plugin name="cordova-plugin-statusbar" source="npm" spec="~2.1.2" />
<plugin name="cordova-plugin-vibration" source="npm" spec="~2.1.0" />
<plugin name="cordova-plugin-whitelist" source="npm" spec="~1.2.1" />
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
<allow-intent href="market:*" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
謝謝,但插件已經包含在我的代碼<插件名稱=「科爾多瓦-插件-地理位置「source =」npm「/>。 – meetrk85
您是否已將'cordova.js'添加到您的'.html'文件中,或者如果您正在通過'PhoneGap Build Online'構建應用程序,然後添加'phonegap.js'也嘗試在'deviceready event listner'上調用此函數 –
已嘗試這也沒有運氣。我沒有物理裝備,它可能是模擬器上的問題嗎? – meetrk85