|
| 1 | +<html> |
| 2 | + <head> |
| 3 | + <title>Itowns - Globe WFS color</title> |
| 4 | + |
| 5 | + <meta charset="UTF-8"> |
| 6 | + <link rel="stylesheet" type="text/css" href="css/example.css"> |
| 7 | + <link rel="stylesheet" type="text/css" href="css/loading_screen.css"> |
| 8 | + |
| 9 | + <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| 10 | + <script src="js/GUI/dat.gui/dat.gui.min.js"></script> |
| 11 | + </head> |
| 12 | + <body> |
| 13 | + <div id="viewerDiv"></div> |
| 14 | + <script src="js/GUI/GuiTools.js"></script> |
| 15 | + <script src="../dist/itowns.js"></script> |
| 16 | + <script src="js/loading_screen.js"></script> |
| 17 | + <script src="../dist/debug.js"></script> |
| 18 | + <div class="help" style="left: unset; right: 0;"> |
| 19 | + <p><b>Information Batiment</b></p> |
| 20 | + <ul id="info"> |
| 21 | + </ul> |
| 22 | + </div> |
| 23 | + <script type="text/javascript"> |
| 24 | + // # Simple Globe viewer |
| 25 | + |
| 26 | + // Define initial camera position |
| 27 | + var positionOnGlobe = { longitude: 4.818, latitude: 45.7354, altitude: 3000 }; |
| 28 | + var promises = []; |
| 29 | + var meshes = []; |
| 30 | + var linesBus = []; |
| 31 | + var scaler; |
| 32 | + |
| 33 | + // `viewerDiv` will contain iTowns' rendering area (`<canvas>`) |
| 34 | + var viewerDiv = document.getElementById('viewerDiv'); |
| 35 | + |
| 36 | + // Instanciate iTowns GlobeView* |
| 37 | + var globeView = new itowns.GlobeView(viewerDiv, positionOnGlobe); |
| 38 | + setupLoadingScreen(viewerDiv, globeView); |
| 39 | + function addLayerCb(layer) { |
| 40 | + return globeView.addLayer(layer); |
| 41 | + } |
| 42 | + |
| 43 | + // Define projection that we will use (taken from https://epsg.io/3946, Proj4js section) |
| 44 | + itowns.proj4.defs('EPSG:3946', |
| 45 | + '+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'); |
| 46 | + |
| 47 | + // Add one imagery layer to the scene |
| 48 | + // This layer is defined in a json file but it could be defined as a plain js |
| 49 | + // object. See Layer* for more info. |
| 50 | + promises.push(itowns.Fetcher.json('./layers/JSONLayers/Ortho.json').then(addLayerCb)); |
| 51 | + |
| 52 | + // Add two elevation layers. |
| 53 | + // These will deform iTowns globe geometry to represent terrain elevation. |
| 54 | + promises.push(itowns.Fetcher.json('./layers/JSONLayers/WORLD_DTM.json').then(addLayerCb)); |
| 55 | + promises.push(itowns.Fetcher.json('./layers/JSONLayers/IGN_MNT_HIGHRES.json').then(addLayerCb)); |
| 56 | + |
| 57 | + promises.push(globeView.addLayer({ |
| 58 | + type: 'color', |
| 59 | + id: 'wfsBuilding', |
| 60 | + transparent: true, |
| 61 | + style: { |
| 62 | + fill: 'red', |
| 63 | + fillOpacity: 0.5, |
| 64 | + stroke: 'white', |
| 65 | + }, |
| 66 | + projection: 'EPSG:4326', |
| 67 | + source: { |
| 68 | + url: 'http://wxs.ign.fr/72hpsel8j8nhb5qgdh07gcyp/geoportail/wfs?', |
| 69 | + networkOptions: { crossOrigin: 'anonymous' }, |
| 70 | + protocol: 'wfs', |
| 71 | + version: '2.0.0', |
| 72 | + typeName: 'BDTOPO_BDD_WLD_WGS84G:bati_remarquable,BDTOPO_BDD_WLD_WGS84G:bati_indifferencie,BDTOPO_BDD_WLD_WGS84G:bati_industriel', |
| 73 | + zoom: { max: 20, min: 15 }, |
| 74 | + projection: 'EPSG:4326', |
| 75 | + extent: { |
| 76 | + west: 4.568, |
| 77 | + east: 5.18, |
| 78 | + south: 45.437, |
| 79 | + north: 46.03, |
| 80 | + }, |
| 81 | + ipr: 'IGN', |
| 82 | + format: 'application/json', |
| 83 | + }, |
| 84 | + })); |
| 85 | + |
| 86 | + var menuGlobe = new GuiTools('menuDiv', globeView); |
| 87 | + // Listen for globe full initialisation event |
| 88 | + globeView.addEventListener(itowns.GLOBE_VIEW_EVENTS.GLOBE_INITIALIZED, function () { |
| 89 | + // eslint-disable-next-line no-console |
| 90 | + console.info('Globe initialized'); |
| 91 | + Promise.all(promises).then(function () { |
| 92 | + menuGlobe.addImageryLayersGUI(globeView.getLayers(function (l) { return l.type === 'color'; })); |
| 93 | + menuGlobe.addElevationLayersGUI(globeView.getLayers(function (l) { return l.type === 'elevation'; })); |
| 94 | + itowns.ColorLayersOrdering.moveLayerToIndex(globeView, 'Ortho', 0); |
| 95 | + }).catch(console.error); |
| 96 | + }); |
| 97 | + var d = new debug.Debug(globeView, menuGlobe.gui); |
| 98 | + debug.createTileDebugUI(menuGlobe.gui, globeView, globeView.wgs84TileLayer, d); |
| 99 | + </script> |
| 100 | + </body> |
| 101 | +</html> |
0 commit comments