Я использую сборку http://openlayers.org/ol-cesium/
У меня на карте OSM-подложка и мой слой из GeoServer'а (пробовал WMS и кешированный WMTS).
В "плоском" режиме - режиме OpenLayers все слои видны.
При включении режима Cesuim'а (ol3d.setEnabled(true) ) пропадает мой растровый слой из GeoServer'а.
Вот код:
Код: Выделить всё
//var projection = new ol.proj.Projection({code:"EPSG:3875"});
var projection = new ol.proj.get('EPSG:900913');
var projectionExtent = projection.getExtent();
console.log(projectionExtent);
var size = ol.extent.getWidth(projectionExtent) / 256;
var resolutions = new Array(18);
var matrixIds = new Array(18);
for (var z = 0; z < 18; ++z) {
// generate resolutions and matrixIds arrays for this WMTS
resolutions[z] = size / Math.pow(2, z);
matrixIds[z] ='EPSG:900913:' + z;
//matrixIds[z] = z;
}
;
var tileGrid = new ol.tilegrid.WMTS(
{
origin: ol.extent.getTopLeft(projectionExtent),
resolutions: resolutions,
matrixIds: matrixIds
}
);
var layers = [
new ol.layer.Tile({
source: new ol.source.OSM()
})
,
new ol.layer.Tile({
source: new ol.source.WMTS({
url: 'http://my.ip.76.56:8080/geoserver/gwc/service/wmts',
format: 'image/png',
layer: "bigland:rest_test_Mercator",
projection: projection,
tileGrid: tileGrid,
wrapX: true,
matrixSet: 'EPSG:900913'
})
})
// new ol.layer.Tile({
// source: new ol.source.TileWMS({
// url: 'http://my.ip.76.56:8080/geoserver/wms',
// format: 'image/png',
// params: {'LAYERS': "bigland:rest_test_Mercator", "tiled": "true"}
// })
// })
];
var map = new ol.Map({
layers: layers,
target: 'map',
view: new ol.View({
center: [3830333, 7606624],
zoom: 14
})
});
Cesium.Ion.defaultAccessToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJmZGY3NDlhMC00M2EyLTRmNTAtOGUyNS05Y2NkNzA1YTdlNzAiLCJpZCI6Mj';
var ol3d = new olcs.OLCesium({map: map}); // map is the ol.Map instance
var scene = ol3d.getCesiumScene();
scene.terrainProvider = Cesium.createWorldTerrain();
ol3d.setEnabled(false);
document.getElementById('enable').addEventListener('click', () => ol3d.setEnabled(!ol3d.getEnabled()));