按照switch2osm.org 上的指南,我能够让我自己的 OSM tile 服务器运行。
我确实使用 webbrowser 验证了我的 OSM 磁贴服务器的状态。例如在http://localhost/osm_tiles/0/0/0.png我得到小图片 od world。Evertthing 似乎在我的服务器端工作。
连接到在线地图资源的铯也可以正常工作。
当我尝试将 Cesium 连接到本地 OSM 服务器时,会出现问题。在 Firefox 控制台中,我收到此错误:
““发生错误:获取图像瓦片失败 X:1 Y:1 级别:1。” Cesium.js:381:25514 ““发生错误:无法获取图像平铺 X:1 Y:0 级别:1。” Cesium.js:381:25514 ““出现错误:获取图像瓦片 X:0 Y:0 级别:1 失败。” Cesium.js:381:25514 ““发生错误:无法获取图像平铺 X:0 Y:1 级别:1。” 铯.js:381:25514
我被这个问题困扰了几天。搜索网络并没有为我提供任何有用的线索。
这是我正在运行 Cesium 的网页的源代码:
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Use correct character set. -->
<meta charset="utf-8">
<!-- Tell IE to use the latest, best version (or Chrome Frame if pre-IE11). -->
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
<!-- Make the application on mobile take up the full browser screen and disable user scaling. -->
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
<title>Hello World!</title>
<script src="../Build/Cesium/Cesium.js"></script>
<style>
@import url(../Build/Cesium/Widgets/widgets.css);
html, body, #cesiumContainer {
width: 100%; height: 100%; margin: 0; padding: 0; overflow: hidden;
}
</style>
</head>
<body>
<div id="cesiumContainer"></div>
<script>
//Initialize the viewer widget with several custom options and mixins.
var viewer = new Cesium.Viewer('cesiumContainer', {
//Hide the base layer picker
baseLayerPicker : false,
//Use OpenStreetMaps
imageryProvider : new Cesium.OpenStreetMapImageryProvider({
url : 'http://localhost/osm_tiles/'
//url : '//a.tile.openstreetmap.org/'
}),
// Show Columbus View map with Web Mercator projection
// mapProjection : new Cesium.WebMercatorProjection()
});
//Add basic drag and drop functionality
viewer.extend(Cesium.viewerDragDropMixin);
//Show a pop-up alert if we encounter an error when processing a dropped file
viewer.dropError.addEventListener(function(dropHandler, name, error) {
console.log(error);
window.alert(error);
});
</script>
</body>
</html>