Hello,
i need your kindle help please.
i’m trying to build a webmap using ol3-cesium libraries , when I switch 2d map to 3d map my polygon (geojson or geoserver wms, wfs) are not draped on stk-terrain but they are under the ground.
I tried to use geometry data both in EPSG 3857 that in EPSG 4326, but my polygons still remain under the ground.
I tried to load my polygon (wms and geojson) on the ol3-cesium example
http://openlayers.org/ol3-cesium/examples/epsg-4326.html
on 2d map they are correctly located but when I switch to 3d map the geometries disappear.
Unfortunately, I cannot understand why, if it is only a coordinates problem.
I think I know openlayer use EPSG 3857 and automatically projects the geometries to EPSG 4326, so it makes no difference to have the data in EPSG 3857 or EPSG 4326 , for cesium libraries it’s the same?
Thank you.
This is an excerpt of my code:
_myStroke_ghiacciai = new ol.style.Stroke({
color : 'rgba(0,0,255,1.0)',
width : 0.8
});
_myFill_ghiacciai = new ol.style.Fill({
color: 'rgba(0,0,255,0.2)'
});
myStyle_ghiacciai = new ol.style.Style({
stroke : _myStroke_ghiacciai ,
fill : _myFill_ghiacciai
});
var ghiacciai = new ol.layer.Vector({
title: 'Ghiacciai',
visible: true,
source: new ol.source.Vector({
url: 'data/ghiacciai.json',
projection: 'EPSG:3857',
format: new ol.format.GeoJSON()
}) ,
style: myStyle_ghiacciai });
view = new ol.View({
projection: ‘EPSG:3857’,
center: ol.proj.transform([9.5, 46.1], ‘EPSG:4326’, ‘EPSG:3857’),
zoom: 8,
maxZoom: 14,
minZoom: 7
zoomFactor: 2
});
var map = new ol.Map({
target: ‘map’,
controls: ol.control.defaults().extend([
new ol.control.ScaleLine(),
new ol.control.ZoomSlider(),
]),
renderer: ‘canvas’,
layers: [
new ol.layer.Group({
‘title’: ‘Base maps’
layers: [
new ol.layer.Tile({ title: ‘Ortofoto con strade’,
type: ‘base’,
visible: false,
source: new ol.source.XYZ({
url: ‘http://api.tiles.mapbox.com/v4/digitalglobe.nmmigejm/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoiZGlnaXRhbGdsb2JlIiwiYSI6ImNpZnB2bWUzNDZoczlzaWtxMmd2bDc3ZHQifQ.AHiF6mR5aXL0rdI4eLz2dA’, // You will need to replace the ‘access_token’ and ‘Map ID’ values with your own. http://developer.digitalglobe.com/docs/maps-api
attribution: “© DigitalGlobe, Inc”
})
}),
new ol.layer.Tile({
title: ‘Ortofoto’,
type: ‘base’,
visible: false,
source: new ol.source.XYZ({
attributions: [
new ol.Attribution({
html: ‘Tiles © <a href="http://services.arcgisonline.com/ArcGIS/’ +
‘rest/services/World_Topo_Map/MapServer">ArcGIS</a>’
})
],
url: ‘http://server.arcgisonline.com/ArcGIS/rest/services/’ +
‘World_Imagery/MapServer/tile/{z}/{y}/{x}’
})
}),
new ol.layer.Tile({
title: ‘Topografica’,
type: ‘base’,
visible: true,
source: new ol.source.XYZ({
attributions: [
new ol.Attribution({
html: ‘Tiles © <a href="http://services.arcgisonline.com/ArcGIS/’ +
‘rest/services/World_Topo_Map/MapServer">ArcGIS</a>’ })],url: ‘http://server.arcgisonline.com/ArcGIS/rest/services/’ +‘World_Topo_Map/MapServer/tile/{z}/{y}/{x}’})
}),
new ol.layer.Tile({
title: ‘Stradario’,
type: ‘base’,
visible: false,
source: new ol.source.XYZ({
attributions: [new ol.Attribution({
html: ‘Tiles © <a href="http://services.arcgisonline.com/ArcGIS/’ +
‘rest/services/World_Topo_Map/MapServer">ArcGIS</a>’ } ],
url: ‘http://server.arcgisonline.com/ArcGIS/rest/services/’ +
‘World_Street_Map/MapServer/tile/{z}/{y}/{x}’ })})
] }),
new ol.layer.Group({
title: ‘Overlays’,
layers: [ghiacciai ] }) ],
view: view });
var layerSwitcher = new ol.control.LayerSwitcher({
tipLabel: 'Legenda'
});
map.addControl(layerSwitcher);
var zoomToExtentControl = new ol.control.ZoomToExtent({
label: 'Home',
extent:[1007934.024, 5888053.048, 1190159.773, 5768785.981],
target: document.getElementById('home')
});
map.addControl(zoomToExtentControl);
var ol3d = new olcs.OLCesium({map: map});
var scene = ol3d.getCesiumScene();
var terrainProvider = new Cesium.CesiumTerrainProvider({
url : '//assets.agi.com/stk-terrain/world',
requestWaterMask : true,
requestVertexNormals : false
});
scene.terrainProvider = terrainProvider;
ol3d.setEnabled(false);