itowns
Version:
A JS/WebGL framework for 3D geospatial data visualization
94 lines (82 loc) • 3.77 kB
HTML
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Itowns - Orthographic camera</title>
<link rel="stylesheet" type="text/css" href="css/example.css">
<link rel="stylesheet" type="text/css" href="css/LoadingScreen.css">
<link rel="stylesheet" type="text/css" href="css/widgets.css">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdnjs.cloudflare.com/ajax/libs/dat-gui/0.7.6/dat.gui.min.js"></script>
</head>
<body>
<div id="description">
Key bindings
<ul>
<li>Left-Click : camera translation (drag)</li>
<li>Spacebar / Wheel-Click : smart travel</li>
<li>Mouse Wheel : zoom in/out</li>
<li>Y : move camera to start position</li>
</ul>
</div>
<div id="viewerDiv"></div>
<script src="../dist/itowns.js"></script>
<script src="../dist/debug.js"></script>
<script src="../dist/itowns_widgets.js"></script>
<script src="js/GUI/LoadingScreen.js"></script>
<script src="js/GUI/GuiTools.js"></script>
<script type="text/javascript">
/* global itowns, setupLoadingScreen, GuiTools, debug */
itowns.proj4.defs(
'EPSG:3946',
'+proj=lcc +lat_1=45.25 +lat_2=46.75 +lat_0=46 +lon_0=3 +x_0=1700000 +y_0=5200000 +ellps=GRS80 ' +
'+towgs84=0,0,0,0,0,0,0 +units=m +no_defs'
);
// define geographic extent : CRS, min/max X, min/max Y
const extent = new itowns.Extent(
'EPSG:3946',
1837816.94334, 1847692.32501,
5170036.45870, 5178412.82698,
);
// `viewerDiv` will contain iTowns' rendering area (`<canvas>`)
const viewerDiv = document.getElementById('viewerDiv');
// instantiate PlanarView with an orthographic camera.
// The extent passed in `placement` is the area that will be displayed by camera.
const view = new itowns.PlanarView(viewerDiv, extent, {
camera: { type: itowns.CAMERA_TYPE.ORTHOGRAPHIC },
placement: new itowns.Extent('EPSG:3946', 1838000, 1842000, 5172000, 5174000),
controls: {
// limit the zoom to a resolution interval
maxResolution: 0.01, // a pixel shall not represent a metric size smaller than 1 cm
minResolution: 100, // a pixel shall not represent a metric size larger than 100m
}
});
setupLoadingScreen(viewerDiv, view);
// add a WMS imagery source
const wmsImagerySource = new itowns.WMSSource({
extent: extent,
name: 'ortho_latest',
url: 'https://imagerie.data.grandlyon.com/wms/grandlyon',
version: '1.3.0',
crs: 'EPSG:3946',
format: 'image/jpeg',
});
// add a WMS imagery layer
const wmsImageryLayer = new itowns.ColorLayer('wms_imagery', {
source: wmsImagerySource,
});
view.addLayer(wmsImageryLayer);
// Add a scale :
const scale = new itowns_widgets.Scale(view, {
position: 'bottom-right',
translate: { x: -70 },
});
// request redraw
view.notifyChange();
// add `Controls` menu
if (view.isDebugMode) {
const menu = new GuiTools('menuDiv', view);
debug.createTileDebugUI(menu.gui, view);
}
</script>
</body>
</html>