gpt4 book ai didi

javascript - 铯 : Using own OpenStreetMap server. : 'Failed to obtain image tile' 错误

转载 作者:太空狗 更新时间:2023-10-29 11:13:37 28 4
gpt4 key购买 nike

正在关注 guide at switch2osm.org我能够运行自己的 OSM tile 服务器。

我确实通过使用 webrowser 验证了我的 OSM tile 服务器的状态。例如在 http://localhost/osm_tiles/0/0/0.png我得到小图片 od 世界。对我来说,Eve​​rtthing 似乎在服务器端工作。

连接到在线 map 源的 Cesium 也能正常工作。

当我尝试将 Cesium 连接到本地 OSM 服务器时,问题弹出。在 Firefox 控制台中,我收到此错误:

"An error occurred in "": Failed to obtain image tile X: 1 Y: 1 Level: 1." Cesium.js:381:25514 "An error occurred in "": Failed to obtain image tile X: 1 Y: 0 Level: 1." Cesium.js:381:25514 "An error occurred in "": Failed to obtain image tile X: 0 Y: 0 Level: 1." Cesium.js:381:25514 "An error occurred in "": Failed to obtain image tile X: 0 Y: 1 Level: 1." Cesium.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>

最佳答案

您是否在您的切片服务器上启用了 CORS(跨源资源共享)?源定义为 URI 方案、主机名和端口号。即使您的 tileserver 和 Cesium 都在本地主机上运行,​​您也需要配置服务器以提供 CORS header ,以便 Cesium 使用图像。参见 http://enable-cors.org/server_apache.html有关如何在 osm apache 服务器上配置 CORS 的说明。

关于javascript - 铯 : Using own OpenStreetMap server. : 'Failed to obtain image tile' 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28946739/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com