UNPKG

itowns

Version:

A JS/WebGL framework for 3D geospatial data visualization

116 lines (99 loc) 4.59 kB
<html> <head> <title>Itowns - Planar example</title> <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"> <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>Right-Click: camera translation (pan)</li> <li>Ctrl + Left-Click: camera rotation (orbit)</li> <li>Spacebar / Wheel-Click: smart zoom</li> <li>Mouse Wheel: zoom in/out</li> <li>T: orient camera to a top view</li> <li>Y: move camera to start position</li> </ul> </div> <div id="viewerDiv" class="viewer"></div> <script src="../dist/itowns.js"></script> <script src="js/GUI/LoadingScreen.js"></script> <script src="../dist/debug.js"></script> <script src="js/GUI/GuiTools.js"></script> <script type="text/javascript"> // Define projection that we will use (taken from https://epsg.io/3946, Proj4js section) 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'); /* global itowns, setupLoadingScreen, GuiTools, debug */ // # Planar (EPSG:3946) viewer var extent; var viewerDiv; var view; var p; var menuGlobe; var d; // Define geographic extent: CRS, min/max X, min/max Y extent = new itowns.Extent( 'EPSG:3946', 1837816.94334, 1847692.32501, 5170036.4587, 5178412.82698); // `viewerDiv` will contain iTowns' rendering area (`<canvas>`) viewerDiv = document.getElementById('viewerDiv'); // Instanciate PlanarView* view = new itowns.PlanarView(viewerDiv, extent, { disableSkirt: true }); setupLoadingScreen(viewerDiv, view); // Add a WMS imagery source var wmsImagerySource = new itowns.WMSSource({ extent: extent, name: 'Ortho2009_vue_ensemble_16cm_CC46', url: 'https://download.data.grandlyon.com/wms/grandlyon', version: '1.3.0', projection: 'EPSG:3946', format: 'image/jpeg', }); // Add a WMS imagery layer var wmsImageryLayer = new itowns.ColorLayer('wms_imagery', { updateStrategy: { type: itowns.STRATEGY_DICHOTOMY, options: {}, }, source: wmsImagerySource, }); view.addLayer(wmsImageryLayer); // Add a WMS elevation source var wmsElevationSource = new itowns.WMSSource({ extent: extent, url: 'https://download.data.grandlyon.com/wms/grandlyon', name: 'MNT2012_Altitude_10m_CC46', projection: 'EPSG:3946', width: 256, format: 'image/jpeg', }); // Add a WMS elevation layer var wmsElevationLayer = new itowns.ElevationLayer('wms_elevation', { useColorTextureElevation: true, colorTextureElevationMinZ: 37, colorTextureElevationMaxZ: 240, source: wmsElevationSource, }); view.addLayer(wmsElevationLayer); p = { coord: extent.center(), heading: -49.6, range: 6200, tilt: 17 }; itowns.CameraUtils.transformCameraToLookAtTarget(view, view.camera.camera3D, p); // instanciate controls // eslint-disable-next-line no-new new itowns.PlanarControls(view, {}); // Request redraw view.notifyChange(); if (view.isDebugMode) { menuGlobe = new GuiTools('menuDiv', view); menuGlobe.addImageryLayersGUI(view.getLayers(function gui(l) { return l.isColorLayer; })); menuGlobe.addElevationLayerGUI(wmsElevationLayer); debug.createTileDebugUI(menuGlobe.gui, view); } </script> </body> </html>