Munich Technical University || Chair of Geoinformatics
Murat Kendir, Prof. Thomas Kolbe || murat.kendir@tum.de
<title>My Web Page</title>
<div align="center">
<h1>Welcome to my website!</h1>
<p align="right">This is my first web page design.</p>
<p align="left">I am still very excited to make this.</p>
</div>
<title>My Web Page</title>
<style>
h1 {text-align:center;}
p {text-align:left;}
</style>
<div>
<h1>Welcome to my website!</h1>
<p>This is my first web page design.</p>
<p>I am still very excited to make this.</p>
</div>
<title>My Web Page</title>
<style>
#title1 {text-align:center;}
#paragraph1 {text-align:left;}
.right {text-align:right;}
</style>
<div>
<h1 id="title1">Welcome to my website!</h1>
<p class="right">This is my first web page design.</p>
<p id="paragraph1">I am still very excited to make this.</p>
</div>
<title>My Web Page</title>
<style>
#title1 {text-align:center;}
#paragraph1 {text-align:left;}
.right {text-align:right;}
</style>
<div>
<h1 id="title1">Welcome to my website!</h1>
<p class="right">This is my first web page design.</p>
<p id="paragraph1">I am still very excited to make this.</p>
<p id="paragraph1" class="right">What an exciting moment.</p>
</div>
<title>My Web Page</title>
<link rel="stylesheet" href="my_style.css">
<div>
<h1 id="title1">Welcome to my website!</h1>
<p class="right">This is my first web page design.</p>
<p id="paragraph1">I am still very excited to make this.</p>
<p id="paragraph1" class="right">What an exciting moment.</p>
</div>
<title>My Web Page</title>
<link rel="stylesheet" href="https://www.neredekaliyor.com/koordinat_paylasma/my_style.css">
<div>
<h1 id="title1">Welcome to my website!</h1>
<p class="right">This is my first web page design.</p>
<p id="paragraph1">I am still very excited to make this.</p>
<p id="paragraph1" class="right">What an exciting moment.</p>
</div>
An Example: ThreeJS
<html>
<head>
<script src="https://cdn.jsdelivr.net/npm/ol@v7.2.2/dist/ol.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/ol@v7.2.2/ol.css">
<title>Empty Map with defaults</title>
<link rel="stylesheet" href="demo3a.css"></link>
</head>
<body>
<div id="map"></div>
<div class="box"> Check the style of this box. </div>
<script type="text/javascript" src="demo3a.js"></script>
</body>
</html>
var map = new ol.Map({
target: 'map',
layers: [
new ol.layer.Tile({
source: new ol.source.OSM()})
],
view: new ol.View({
center: [1287392,6123424],
zoom: 10
})
});
console.dir(map)
in the (Web) Developer Tool of browserconsole.log(map.targetElement_)
console.dir(map)
console.log(map.viewPropertyListenerKey_.target.values_)
Which one is a correct definition for a WMS service in OpenLayers?
A
new ol.layer.Image({
source: new ol.source.ImageWMS({
url: 'https://geoportal.muenchen.de/geoserver/gsm_wfs/awm_wertstoffhoefe_opendata/ows',
params: {'LAYERS': 'awm_wertstoffhoefe_opendata'},
}),
B
new Image({
source: new ImageWMS({
url: 'https://geoportal.muenchen.de/geoserver/gsm_wfs/awm_wertstoffhoefe_opendata/ows',
params: {'LAYERS': 'awm_wertstoffhoefe_opendata'},
}),
Method 1: Check the debugger tool in (Web) Developer Tool.
Method 2: Check the documentation of the used library (e.g. OpenLayers API Doc ).
Check the GetFeatureInfo operation's documentation: OGC e-Learning
Check the following classes/methods in OpenLayers API Doc:
map.on('singleclick', function (evt) {
//console.log(evt);
document.getElementById('topright_box').innerHTML = '';
const viewResolution = view.getResolution();
const url = wmsSource.getFeatureInfoUrl(
evt.coordinate,
viewResolution,
'EPSG:3857',
{'INFO_FORMAT': 'text/plain'},
);
});
map.on('singleclick', function (evt) {
//console.log(evt);
document.getElementById('topright_box').innerHTML = '';
const viewResolution = view.getResolution();
const url = wmsSource.getFeatureInfoUrl(
evt.coordinate,
viewResolution,
'EPSG:3857',
{'INFO_FORMAT': 'text/plain'},
);
if (url) {
fetch(url)
.then((response) => response.text())
.then((html) => {
document.getElementById('topright_box').innerHTML = html;
});
}
});
USGS WMTS service (Capabilities)
A
const my_wmts = new ol.layer.Tile({
opacity: 0.5,
source: new ol.source.WMTS({
url: 'https://mrdata.usgs.gov/mapcache/wmts',
layer: 'sgmc2',
width: '256px',
height: '256px',
format: 'image/png',
}),
});
B
const my_wmts = new ol.layer.Tile({
opacity: 0.5,
source: new ol.source.WMTS({
url: 'https://mrdata.usgs.gov/mapcache/wmts',
layer: 'sgmc2',
matrixSet: 'GoogleMapsCompatible',
format: 'image/png',
}),
});
const projection = ol.proj.get('EPSG:3857');
const projectionExtent = projection.getExtent();
console.log('Projection Extent : ', projectionExtent);
const size = ol.extent.getWidth(projectionExtent) / 256;
console.log('Size : ' , size);
const resolutions = new Array(19);
const matrixIds = new Array(19);
for (let z = 0; z < 19; ++z) {
// generate resolutions and matrixIds arrays for this WMTS
resolutions[z] = size / Math.pow(2, z);
matrixIds[z] = z;
}
const my_wmts = new ol.layer.Tile({
opacity: 0.5,
source: new ol.source.WMTS({
url: 'https://mrdata.usgs.gov/mapcache/wmts',
layer: 'sgmc2',
matrixSet: 'GoogleMapsCompatible',
format: 'image/png',
projection: projection,
tileGrid: new ol.tilegrid.WMTS({
origin: ol.extent.getTopLeft(projectionExtent),
resolutions: resolutions,
matrixIds: matrixIds,
}),
style: 'default',
wrapX: false,
}),
});
<html lang="en">
<head>
<title>Cesium Demo</title>
<script src="../cesium/Build/Cesium/Cesium.js"></script>
<link href="../cesium/Build/Cesium/Widgets/widgets.css" rel="stylesheet">
</head>
<body style="width:100%;height:100%;">
<div id="cesiumContainer"></div>
<script>
// Initialize the Cesium Viewer in the HTML element with the `cesiumContainer` ID.
const viewer = new Cesium.Viewer('cesiumContainer', {
//Use OpenStreetMaps
imageryProvider : new Cesium.OpenStreetMapImageryProvider({
url : 'https://a.tile.openstreetmap.org/'
}),
});
</script>
</div>
</body>
</html>
Cesium with online repositories
<html lang="en">
<head>
<title>Cesium Demo</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/cesium/1.124.0/Cesium.js"></script>
<link href="https://cdn.jsdelivr.net/npm/cesium@1.124.0/Build/Cesium/Widgets/widgets.min.css" rel="stylesheet">
</head>
<body style="width:100%;height:100%;">
<div id="cesiumContainer"></div>
<script>
// Initialize the Cesium Viewer in the HTML element with the `cesiumContainer` ID.
const viewer = new Cesium.Viewer('cesiumContainer', {
//Use OpenStreetMaps
imageryProvider : new Cesium.OpenStreetMapImageryProvider({
url : 'https://a.tile.openstreetmap.org/'
}),
});
</script>
</div>
</body>
</html>
Cesium with camera initialization
// Fly the camera to San Francisco at the given longitude, latitude, and height.
viewer.camera.flyTo({
destination : Cesium.Cartesian3.fromDegrees(11.575,48.107, 4000),
orientation : {
heading : Cesium.Math.toRadians(0.0),
pitch : Cesium.Math.toRadians(-45.0),
}
});
Enable the "Show Tile Coordinates" and the "Suspend LOD Update" options, then try zooming out.
This is the basic 2D tiling mechanism that used to overlay 2D maps and terrain files.
CesiumJS simply calculates the coverage area and tries to request for the WMS image by comparing with the current view area of the camera (frustum).
Check the Capabilities of a found WMS service: München Bezirksteil
// Add the main URL of WMS service
const geourl = 'https://geoportal.muenchen.de/geoserver/gsm_wfs/vablock_bezirksteil_opendata/ows?';
//Define the WMS service using available parameters
const geoWmsLayer = new Cesium.WebMapServiceImageryProvider({
url : geourl,
parameters: {
service : 'WMS',
format : 'image/png',
transparent : true,
},
layers : 'vablock_bezirksteil_opendata',
EPSG: '4326'
});
//Add to the list of imagery layers of the current viewer.
viewer.imageryLayers.addImageryProvider(geoWmsLayer);
//Change the token here below
Cesium.Ion.defaultAccessToken = "xyzabcxyzabcxyzabcxyzabcxyzabcxyzabcxyzabcxyzabcxyzabcxyzabcxyzabcxyzabcxyzabc";
viewer.scene.setTerrain(
new Cesium.Terrain(
Cesium.CesiumTerrainProvider.fromIonAssetId(1),
),
);
var tileset = viewer.scene.primitives.add(new Cesium.Cesium3DTileset({
url: 'https://web3d.basemap.de/cesium/buildings-fly/root.json'
}));
var cityStyle = new Cesium.Cesium3DTileStyle({
color : {
conditions : [
["${surface} === 'wall'", "color('#f2f2f2')"],
["${surface} === 'roof'", "color('#ff5c4d')"],
["${surface} === 'bridge'", "color('#999999')"]
]
},
});
Cesium with 3D Tiles and Inspector
viewer.extend(Cesium.viewerCesium3DTilesInspectorMixin);