itowns
Version:
A JS/WebGL framework for 3D geospatial data visualization
94 lines (80 loc) • 3.82 kB
HTML
<html>
<head>
<title>Itowns - TIFF Parser with tiled images</title>
<script type="importmap">
{
"imports": {
"itowns": "../dist/itowns.js",
"debug": "../dist/debug.js",
"dat": "https://unpkg.com/dat.gui@0.7.9/build/dat.gui.module.js",
"GuiTools": "./jsm/GUI/GuiTools.js",
"LoadingScreen": "./jsm/GUI/LoadingScreen.js",
"itowns_widgets": "../dist/itowns_widgets.js",
"three": "https://unpkg.com/three@0.170.0/build/three.module.js",
"UTIF": "https://esm.sh/utif",
"TIFFParser": "./jsm/plugins/TIFFParser.js",
"three/addons/": "https://unpkg.com/three@0.170.0/examples/jsm/"
}
}
</script>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="css/example.css">
<link rel="stylesheet" type="text/css" href="css/LoadingScreen.css">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<div id="viewerDiv"></div>
<script type="module">
import GuiTools from 'GuiTools';
import setupLoadingScreen from 'LoadingScreen';
import * as THREE from 'three';
import * as itowns from 'itowns';
import * as debug from 'debug';
import * as itowns_widgets from 'itowns_widgets';
import TIFFParser from 'TIFFParser';
// # Simple Globe viewer
// Define initial camera position
var placement = {
coord: new itowns.Coordinates('EPSG:4326', 1.411667, 43.6074422),
range: 25000000,
}
// `viewerDiv` will contain iTowns' rendering area (`<canvas>`)
var viewerDiv = document.getElementById('viewerDiv');
// Instanciate iTowns GlobeView*
var view = new itowns.GlobeView(viewerDiv, placement);
var menuGlobe = new GuiTools('menuDiv', view);
setupLoadingScreen(viewerDiv, view);
// Add one imagery layer to the scene, read from TIFFs.
var tiffSource = new itowns.TMSSource({
url: 'https://raw.githubusercontent.com/iTowns/iTowns2-sample-data/master/geoid/localcolors/tiff/${z}/localcolors_${x}_${y}.tif',
tileMatrixSet: 'WGS84G',
crs: 'EPSG:4326',
parser: TIFFParser.parse,
fetcher: itowns.Fetcher.arrayBuffer,
zoom: { min: 0, max: 4 },
});
tiffSource.isInverted = true;
var tiffLayer = new itowns.ColorLayer('tiff', {
source: tiffSource,
});
view.addLayer(tiffLayer).then(menuGlobe.addLayerGUI.bind(menuGlobe));
function addElevationLayerFromConfig(config) {
config.source = new itowns.TMSSource(config.source);
var layer = new itowns.ElevationLayer(config.id, config);
view.addLayer(layer).then(function _(layer) {
layer.scale = 10000;
view.tileLayer.attachedLayers[0].visible = false;
menuGlobe.addLayerGUI(layer);
menuGlobe.elevationGui.open();
menuGlobe.elevationGui.__folders.GEOIDMNT.open();
});
}
itowns.Fetcher.json('./layers/JSONLayers/GeoidMNT.json').then(addElevationLayerFromConfig);
const d = new debug.Debug(view, menuGlobe.gui);
debug.createTileDebugUI(menuGlobe.gui, view, view.tileLayer, d);
window.view = view;
window.itowns = itowns;
window.THREE = THREE;
</script>
</body>
</html>