Cordova应用未显示图块图层

时间:2018-07-10 09:43:40

标签: cordova leaflet

我无法在Cordova应用程序下制作显示其瓷砖图层的传单。 我制作了一个非常基本的Cordova应用程序,并且按照Leaflet tutorial中所述执行了所有步骤。我正在使用通过Bower在本地安装的传单1.3.1。 以下是我的源文件的摘录:

index.css

* {
    -webkit-tap-highlight-color: rgba(0,0,0,0); /* make transparent link selection, adjust last value opacity 0 to 1.0 */
}

body {
    -webkit-touch-callout: none;                /* prevent callout to copy image, etc when tap to hold */
    -webkit-text-size-adjust: none;             /* prevent webkit from resizing text to fit */
    -webkit-user-select: none;                  /* prevent copy paste, to allow, change 'none' to 'text' */
    font-family:'HelveticaNeue-Light', 'HelveticaNeue', Helvetica, Arial, sans-serif;
    font-size:12px;
    height:100%;
    margin:0px;
    padding:0px;
    text-transform:uppercase;
    width:100%;
}

html, body, #mapid {
    height: 100%;
    width: 100vw;
}

index.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="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
        <link rel="stylesheet" type="text/css" href="css/index.css">

        <link rel="stylesheet" type="text/css" href="bower_components/leaflet/dist/leaflet.css">

        <title>Hello World</title>
    </head>
    <body>
        <div id="mapid"></div>

        <script type="text/javascript" src="cordova.js"></script>
        <script type="text/javascript" src="js/index.js"></script>

        <script type="text/javascript" src="bower_components/leaflet/dist/leaflet.js"></script>
    </body>
</html>

index.js

var app = {
    // Application Constructor
    initialize: function() {
        document.addEventListener('deviceready', this.onDeviceReady.bind(this), false);
    },

    // deviceready Event Handler
    //
    // Bind any cordova events here. Common events are:
    // 'pause', 'resume', etc.
    onDeviceReady: function() {
        this.receivedEvent('deviceready');
    },

    // Update DOM on a Received Event
    receivedEvent: function(id) {
        console.log('Received Event: ' + id);

        var map = L.map('mapid').fitWorld();
        L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
            maxZoom: 18
        }).addTo(map);
        console.log('show map');
    }
};

app.initialize();

config.xml

<?xml version='1.0' encoding='utf-8'?>
<widget id="com.example.geo" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:cdv="http://cordova.apache.org/ns/1.0" xmlns:gap="http://phonegap.com/ns/1.0">
    <name>Geo</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" />
    <preference name="android-build-tool" value="gradle" />
    <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:*" />
    <access origin="*" />
    <platform name="android">
        <allow-intent href="market:*" />
    </platform>
    <platform name="ios">
        <allow-intent href="itms:*" />
        <allow-intent href="itms-apps:*" />
    </platform>
    <plugin name="cordova-plugin-whitelist" spec="^1.2.2" />
    <engine name="android" spec="^6.2.0" />
</widget>

请注意,我可以看到地图图层及其控件,例如缩放按钮,传单页脚,因此这种情况与地图的高度值IMO无关。

请参见下面的屏幕截图:

Leaflet Map | Android Simulator

任何反馈将不胜感激,谢谢!

0 个答案:

没有答案