Cordova地理定位不适用于android5

时间:2016-11-08 08:44:52

标签: android cordova

我正在使用Cordova地理定位插件。我在我的应用中添加了地理位置插件。当我运行我的应用程序时,我只看到白页。我的应用程序无法正常工作我试过模拟器,在我的设备上结果没有什么不同。另外我尝试了另一个设备,结果是白页。在我看另一个问题之前,我尝试了不同的解决方法,但它没有用。请帮我。我想解决这个问题。

İt是我的index.html

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *; img-src 'self' data: content:;">
        <meta name="format-detection" content="telephone=no">
        <meta name="msapplication-tap-highlight" content="no">
        <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
        <link rel="stylesheet" type="text/css" href="css/index.css">
        <title>Hello World</title>
    </head>
    <body>
        <div id="map"></div>
        <script type="text/javascript" src="cordova.js"></script>
        <script type="text/javascript" src="js/index.js"></script>
        <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyC18ssJ3hw71l5zkMYBhqBrMxqXWyCGlO8"></script>
    </body>
</html>

是我的index.js

    var app = {
    initialize: function() {
        document.addEventListener('deviceready', this.onDeviceReady.bind(this), false);
    },
    onDeviceReady: function() {
        navigator.geolocation.getCurrentPosition(app.onSuccess, app.onError, app.options);  
    },
        onSuccess:function(position) {
        var lat=position.coords.latitude;
        var lng=position.coords.longitude;
        var LatLong=new google.maps.LatLng(lat,lng);
        var mapOptions={
            center:LatLong,
            zoom:13,
            mapTypeId:google.maps.MapTypeId.ROADMAP
        };
        var map=new google.maps.Map(document.getElementById("map"),mapOptions);
        var marker=new google.maps.Marker({
            position:LatLong,
            map:map,
            title:'location'
        })
    },
        onError:function (error) {
        alert('code: '    + error.code    + '\n' +
              'message: ' + error.message + '\n');
    }   
};
app.initialize();

是我的config.xml

    <?xml version='1.0' encoding='utf-8'?>
<widget id="com.example.geox" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>geox</name>
    <description>
        A sample Apache Cordova application that responds to the deviceready event.
    </description>
    <author email="dev@cordova.apache.org" href="http://cordova.io">
        Apache Cordova Team
    </author>
    <content src="index.html" />
    <plugin name="cordova-plugin-whitelist" spec="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>
</widget>

是我的res / xml / config.xml

    <?xml version='1.0' encoding='utf-8'?>
<widget id="com.example.geox" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <feature name="Geolocation">
        <param name="android-package" value="org.apache.cordova.geolocation.Geolocation" />
    </feature>
    <feature name="Whitelist">
        <param name="android-package" value="org.apache.cordova.whitelist.WhitelistPlugin" />
        <param name="onload" value="true" />
    </feature>
    <feature name="Notification">
        <param name="android-package" value="org.apache.cordova.dialogs.Notification" />
    </feature>
    <name>geox</name>
    <description>
        A sample Apache Cordova application that responds to the deviceready event.
    </description>
    <author email="dev@cordova.apache.org" href="http://cordova.io">
        Apache Cordova Team
    </author>
    <content src="index.html" />
    <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:*" />
    <allow-intent href="market:*" />
    <preference name="loglevel" value="DEBUG" />
</widget>

0 个答案:

没有答案