Hello!
Following guide at switch2osm.org I was able to get my own OSM tile server running.
(Ubuntu linux 14.04, Apache 2.4.7, Cesium-1.6, node-v0.12.0, postgresql-9.3-postgis-2.1, osm2pgsql 0.87.2-dev, Mapnik 2.2.0)
I did have verify state of my OSM tile server by using webrowser. For example at http://localhost/osm_tiles/0/0/0.png I get small picture od world.
Evertthing seems to be working at server side to me.
Cesium connected to online source of maps works fine as well.
Problem pops up, when i try connect Cesium to local OSM server. In Firefox console I get this error:
“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
``
I’m already stuck with this problem for quite a few days. Here is what I have tried and found out so far:
-
Analyse Apache logfiles.
My DEFAULT_ERRORLOG is set to “logs/error_log”, but there is no such file on my system. With documentation on apache.org
i was able locate /var/log/apache2/error.log file.
Per request a identical line pops up in there :
debug: init_storage_backend: initialising file storage backend at: /var/lib/mod_tile
``
I was not able to find any difference in logs on Apache side between request from Cesium and webrowser.
-
Setting Apache and Cesium to run on same port
I was not able to achieve this. Cesium does not like that. Spits at me angrily this:
Error: Port 8080 is already in use, select a different port.
Example: node server.js --port 8081
{ [Error: listen EADDRINUSE] code: ‘EADDRINUSE’, errno: ‘EADDRINUSE’, syscall: ‘listen’ }
``
I achieved this by changing port numbers from 80 to 8080 in files /etc/apache2/ports.conf and /etc/apache2/sites-enabled/000-default.conf .
-
Set Cross Origin Resource Sharing (CORS) on Apache
Maybe I screwed up somewhere in the proces. Here is what I did:
Enabled mod_headers in Apache by
a2enmod headers
``
Changing Apache configuration file */etc/apache2/apache.conf * by adding line
Header set Access-Control-Allow-Origin “*”
``
to existing sections , <Directory /var/www/> and creating own section <Directory /var/lib/mod_tile/> .
Did not forget obligatory reloading server by
sudo service apache2 reload
``
After that I have been left disappointed by result: Still getting the same error.
Pretty please: Do anyone have idea what am I doing wrong?
Here is sourcecode of webpage I’m running Cesium from:
<!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/](http://localhost/osm_tiles/)'
//url : '//[a.tile.openstreetmap.org/](http://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>
``