0

I would like to test the Ol-Cesium on my computer with this example: https://openlayers.org/ol-cesium/examples/oldfashioned.html

I saved the olcs.css, olcesium.js and Cesium.js file into my webserver's folder. So, here is my code (I replaced only the lines where JS and CSS are located).

The 2D view with only OpenLayers is works well, but the 3D Cesium view doesn't. The map is black, and I got no error messages in console.

Do you have any tips what cause this error?

<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="https://cdn.rawgit.com/openlayers/openlayers.github.io/master/en/v5.3.0/css/ol.css" type="text/css">
<link rel="stylesheet" href="olcs.css" type="text/css">
<style>
#map { height: 300px; width: 500px }
</style>
<script src="https://cdn.rawgit.com/openlayers/openlayers.github.io/master/en/v5.3.0/build/ol.js"></script>
<script src="olcesium.js"></script>
<script src="Cesium.js"></script>
</head>
<body>
<p>Old-fashioned example</p>
<input id="enable" type="button" value="Enable/disable" />
<div id="map"></div>
</body>
<script>
var ol2d = new ol.Map({
layers: [
  new ol.layer.Tile({
    source: new ol.source.OSM()
  })
],
target: 'map',
view: new ol.View({
  center: ol.proj.transform([25, 20], 'EPSG:4326', 'EPSG:3857'),
  zoom: 3
})
});

var ol3d = new olcs.OLCesium({
map: ol2d,
});
ol3d.setEnabled(true);

var setEnabled = function() {ol3d.setEnabled(!ol3d.getEnabled())};
document.getElementById('enable').addEventListener('click', setEnabled);
</script>

bumped to the homepage by Community 2 days ago

This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.

  • is the globe really 3D? EPSG:4326', 'EPSG:3857 are both 2D – nmtoken 2 days ago
0

scene.globe.enableLighting = true; should fix it.

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

  • 3
    Welcome to GIS.SE! Could you please present your answer in more detail so that other users can follow your solution approach more easily? Thanks! – root676 Sep 13 at 7:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.