UNPKG

itowns

Version:

A JS/WebGL framework for 3D geospatial data visualization

114 lines (99 loc) 4.43 kB
<html lang="en"> <head> <meta charset="UTF-8"> <title>Itowns - Orthographic camera</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", "three/addons/": "https://unpkg.com/three@0.170.0/examples/jsm/" } } </script> <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"> </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 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'; /* global itowns, setupLoadingScreen, GuiTools, debug */ itowns.CRS.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); } window.view = view; window.itowns = itowns; window.THREE = THREE; </script> </body> </html>