-
Notifications
You must be signed in to change notification settings - Fork 303
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
example(SourceFileKML): add new kml raster file from official source
- Loading branch information
1 parent
6e2a98c
commit 58734ee
Showing
2 changed files
with
95 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
<html> | ||
<head> | ||
<title>Itowns - Globe + color layers from vector data</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="viewerDiv" class="viewer"></div> | ||
<script src="js/GUI/GuiTools.js"></script> | ||
<script src="../dist/itowns.js"></script> | ||
<script src="../dist/debug.js"></script> | ||
<script src="js/GUI/LoadingScreen.js"></script> | ||
<script src="js/plugins/FeatureToolTip.js"></script> | ||
<script type="text/javascript"> | ||
// # Simple Globe viewer | ||
/* global itowns, setupLoadingScreen, GuiTools, ToolTip */ | ||
|
||
// Define initial camera position | ||
var placement = { | ||
coord: new itowns.Coordinates('EPSG:4326', 6.8, 45.9), | ||
} | ||
|
||
// `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/Ortho.json').then(function _(config) { | ||
config.source = new itowns.WMTSSource(config.source); | ||
var layer = new itowns.ColorLayer('Ortho', config); | ||
view.addLayer(layer).then(function _() { | ||
menuGlobe.addLayerGUI.bind(menuGlobe); | ||
itowns.ColorLayersOrdering.moveLayerToIndex(view, 'Ortho', 0); | ||
}); | ||
}); | ||
// Add two elevation layers. | ||
// These will deform iTowns globe geometry to represent terrain elevation. | ||
function addElevationLayerFromConfig(config) { | ||
config.source = new itowns.WMTSSource(config.source); | ||
var layer = new itowns.ElevationLayer(config.id, config); | ||
view.addLayer(layer).then(menuGlobe.addLayerGUI.bind(menuGlobe)); | ||
} | ||
itowns.Fetcher.json('./layers/JSONLayers/WORLD_DTM.json').then(addElevationLayerFromConfig); | ||
itowns.Fetcher.json('./layers/JSONLayers/IGN_MNT_HIGHRES.json').then(addElevationLayerFromConfig); | ||
|
||
// Fetch, Parse and Convert by iTowns | ||
var kmlSource = new itowns.FileSource({ | ||
url: 'https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/2.5_month_depth.kml', | ||
crs: 'EPSG:4326', | ||
format: 'application/kml', | ||
}); | ||
|
||
function offset(properties) { | ||
const sizeIcon = 64; | ||
const scaleIcon = properties['icon-scale']; | ||
return [ 0, -0.5 * scaleIcon * sizeIcon ]; | ||
} | ||
|
||
var kmlStyle = new itowns.Style({ | ||
zoom: { min: 10, max: 20 }, | ||
text: { | ||
field: '{name}', | ||
haloColor: 'black', | ||
haloWidth: 1, | ||
color: 'white', | ||
offset: offset, | ||
anchor: 'bottom', | ||
}, | ||
}); | ||
|
||
var kmlLayer = new itowns.ColorLayer('Kml', { | ||
source: kmlSource, | ||
style: kmlStyle, | ||
addLabelLayer: true, | ||
}); | ||
|
||
debug.createTileDebugUI(menuGlobe.gui, view); | ||
|
||
view.addLayer(kmlLayer).then(FeatureToolTip.addLayer); | ||
</script> | ||
</body> | ||
</html> |