itowns
Version:
A JS/WebGL framework for 3D geospatial data visualization
83 lines (74 loc) • 3.6 kB
HTML
<html>
<head>
<title>Itowns - Parsing VRT + CSV</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>
<script src="https://cdnjs.cloudflare.com/ajax/libs/PapaParse/5.0.1/papaparse.min.js"></script>
</head>
<body>
<div id="viewerDiv"></div>
<script src="js/GUI/GuiTools.js"></script>
<script src="../dist/itowns.js"></script>
<script src="js/GUI/LoadingScreen.js"></script>
<script src="js/plugins/FeatureToolTip.js"></script>
<script src="js/plugins/CSVnVRTParser.js"></script>
<script src="../dist/debug.js"></script>
<script type="text/javascript">
// Define initial camera position
var placement = {
coord: new itowns.Coordinates('EPSG:4326', 2.351323, 48.856712),
range: 25000,
}
// `viewerDiv` will contain iTowns' rendering area (`<canvas>`)
var viewerDiv = document.getElementById('viewerDiv');
// Instanciate iTowns GlobeView*
var view = new itowns.GlobeView(viewerDiv, placement);
var menuGlobe = new GuiTools('menuDiv', view);
setupLoadingScreen(viewerDiv, view);
FeatureToolTip.init(viewerDiv, view);
// Add one imagery layer to the scene
// This layer is defined in a json file but it could be defined as a plain js
// object. See Layer* for more info.
itowns.Fetcher.json('./layers/JSONLayers/OPENSM.json').then(function _(config) {
config.source = new itowns.TMSSource(config.source);
var layer = new itowns.ColorLayer('OPENSM', config);
view.addLayer(layer).then(menuGlobe.addLayerGUI.bind(menuGlobe));
});
// In this case, a VRT is associated to a CSV
itowns.Fetcher.multiple('https://raw.githubusercontent.com/iTowns/iTowns2-sample-data/master/vrt/velib-disponibilite-en-temps-reel', {
xml: ['vrt'],
text: ['csv'],
}).then(function _(res) {
res.csv = Papa.parse(res.csv.trim()).data;
return CSVnVRTParser.parse(res, { out: {
crs: view.tileLayer.extent.crs,
}});
}).then(function _(features) {
var velibSource = new itowns.FileSource({ features });
var velibLayer = new itowns.ColorLayer('velib', {
source: velibSource,
style: {
zoom: { min: 10, max: 20 },
point: {
color: 'cyan',
line: 'red',
radius: 3,
},
text: {
field: '{name}\nCapacity: {Capacity}',
haloColor: 'white',
haloWidth: 1,
},
},
addLabelLayer: true,
});
return view.addLayer(velibLayer);
}).then(function _(layer) {
FeatureToolTip.addLayer(layer, { filterAllProperties: false });
});
</script>
</body>
</html>