Published
Edited
Sep 28, 2020
1 star
Insert cell
Insert cell
Insert cell
viewerDiv = html`<div style='height:400px;' />`
Insert cell
itowns.proj4.defs("EPSG:3857","+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs");


Insert cell
// Define geographic extent: CRS, min/max X, min/max Y
extent = new itowns.Extent( 'EPSG:3857',510927.4,6880931.1, 516303.7,6885672.7);
Insert cell
cameraCoord = new itowns.Coordinates('EPSG:3857', 514302,6883704, 3000)
Insert cell
view = new itowns.PlanarView(viewerDiv, extent, { placement: {
coord: cameraCoord, heading: -30, range: 4000, tilt: 30 } });
Insert cell
Insert cell
// Add a WMS imagery source
wmsImagerySource = new itowns.WMSSource({
extent: extent,
name: 'bgt',
url: 'https://saturnus.geodan.nl/mapproxy/bgt/service',
version: '1.1.1',
projection: 'EPSG:3857',
format: 'image/png',
});
Insert cell
// Add a WMS imagery layer
wmsImageryLayer = new itowns.ColorLayer('wms_imagery', {
updateStrategy: {
type: itowns.STRATEGY_DICHOTOMY,
options: {},
},
source: wmsImagerySource,
});
Insert cell
view.addLayer(wmsImageryLayer);
Insert cell
new itowns.PlanarControls(view, {});
Insert cell
$3dTilesLayer = new itowns.C3DTilesLayer(
'3d-tiles-layer-building', {
name: 'Velsen_buildings',
source: new itowns.C3DTilesSource({
url:
'https://beta.geodan.nl/maquette_nl/data/buildingtiles_velsen_3857/tileset.json',
}),
}, view);

Insert cell
{
var dirLight = new itowns.THREE.DirectionalLight(0xffffff, 1);
dirLight.position.set(-0.9, 0.3, 1);
dirLight.updateMatrixWorld();
view.scene.add( dirLight );

var ambLight = new itowns.THREE.AmbientLight(0xffffff, 0.2);
view.scene.add( ambLight );
// Pick 3D Tiles features when hovering them with the mouse and
// display their semantic information in an html div
var pickingArgs = {};
pickingArgs.htmlDiv = document.getElementById('featureInfo');
pickingArgs.view = view;
pickingArgs.layer = $3dTilesLayer;
itowns.View.prototype.addLayer.call(view, $3dTilesLayer);
// Request redraw
view.notifyChange();
}
Insert cell
Type JavaScript, then Shift-Enter. Ctrl-space for more options. Arrow ↑/↓ to switch modes.

Insert cell
Insert cell
itowns = require('https://cdn.jsdelivr.net/npm/itowns@2.24.1/dist/itowns.js')
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more