地图不显示在带有传单的cordova.js上
cordova上的显示地图有问题。我们没有任何错误,但地图没有显示。我们做错了什么?地图不显示在带有传单的cordova.js上,cordova,leaflet,Cordova,Leaflet,cordova上的显示地图有问题。我们没有任何错误,但地图没有显示。我们做错了什么? (函数(){ “严格使用”; document.addEventListener('devicerady',ondevicerady.bind(this),false); 函数ondevicerady(){ document.addEventListener('pause',onPause.bind(this),false); document.addEventListener('resume',onResu
(函数(){
“严格使用”;
document.addEventListener('devicerady',ondevicerady.bind(this),false);
函数ondevicerady(){
document.addEventListener('pause',onPause.bind(this),false);
document.addEventListener('resume',onResume.bind(this),false);
var map=L.map('mapid').fitWorld();
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'{
属性:“地图数据©;贡献者,图像©”,
最大缩放:18
}).addTo(地图);
};
函数onPause(){
};
函数onResume(){
};
})() 您附加的图像显示您的地图脚本正在加载地图div-您有放大/缩小按钮。但它看起来好像不加载平铺层 首先,检查正在测试的设备/仿真器上是否有internet连接。您可以向应用程序中添加按钮(
index.html
):
您也可以尝试在应用程序中使用不同的tiles提供商,例如Esri(google for others): 或地图框(来自传单示例):
如果你写下更多关于如何测试你的应用程序的细节,这也会很有用。是设备还是模拟器?你确定它有互联网连接吗?您使用的是哪个版本的cordova,您正在为哪些设备编译应用程序?您至少可以显示一个外部图像吗?例如,如果在某个URL中包含
,或http://a.tile.openstreetmap.org/0/0/0.png
?
(function () {
"use strict";
document.addEventListener( 'deviceready', onDeviceReady.bind( this ), false );
function onDeviceReady() {
document.addEventListener( 'pause', onPause.bind( this ), false );
document.addEventListener('resume', onResume.bind(this), false);
var map = L.map('mapid').fitWorld();
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="http://mapbox.com">Mapbox</a>',
maxZoom: 18
}).addTo(map);
};
function onPause() {
};
function onResume() {
};
<button id="home_network_button"> check network?</button>
$("#home_network_button").on('click', function(){
checkConnection();
});
function checkConnection() {
var networkState = navigator.connection.type;
var states = {};
states[Connection.UNKNOWN] = 'Unknown';
states[Connection.ETHERNET] = 'Ethernet connection';
states[Connection.WIFI] = 'WiFi connection';
states[Connection.CELL_2G] = 'Cell 2G connection';
states[Connection.CELL_3G] = 'Cell 3G connection';
states[Connection.CELL_4G] = 'Cell 4G connection';
states[Connection.CELL] = 'Cell generic connection';
states[Connection.NONE] = 'No network';
alert('Netowrk state: ' + states[networkState]);
}
L.tileLayer('http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}', {
maxZoom: 18,
id: 'mapbox.streets'
}).addTo(map);
L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4NXVycTA2emYycXBndHRqcmZ3N3gifQ.rJcFIG214AriISLbB6B5aw', {
maxZoom: 18,
id: 'mapbox.streets'
}).addTo(map);