農研機構・日本土壌インベントリー(土壌図) を Cesium で表示
Created
May 25, 2017 10:19
-
-
Save frogcat/a585166b22c0f50c10f509b018d2115e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
(function(window) { | |
var CS = {}; | |
CS.map = function(element, options) { | |
options = options || {}; | |
var obj = { | |
viewer: new Cesium.Viewer(element, { | |
timeline: false, | |
animation: false, | |
homeButton: false, | |
geocoder: false, | |
sceneModePicker: false, | |
baseLayerPicker: false, | |
fullscreenButton: false, | |
terrainExaggeration: options.terrainExaggeration || 1.0, | |
terrainProvider: new Cesium.CesiumTerrainProvider({ | |
url: "https://assets.agi.com/stk-terrain/world", | |
requestWaterMask: true, | |
requestVertexNormals: true | |
}), | |
imageryProvider: new Cesium.UrlTemplateImageryProvider({ | |
url: 'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=' | |
}) | |
}), | |
setView: function(latLng, heading, pitch) { | |
this.viewer.camera.setView({ | |
destination: Cesium.Cartesian3.fromDegrees(latLng.lng, latLng.lat, latLng.alt), | |
orientation: { | |
heading: Cesium.Math.toRadians(heading), | |
pitch: Cesium.Math.toRadians(pitch), | |
roll: 0 | |
} | |
}); | |
return this; | |
}, | |
addLayer: function(layer) { | |
this.viewer.imageryLayers.addImageryProvider(layer.imageryProvider); | |
return this; | |
} | |
}; | |
return obj; | |
}; | |
CS.latLng = function(lat, lng, alt) { | |
return { | |
lat: lat, | |
lng: lng, | |
alt: alt | |
}; | |
}; | |
CS.tileLayer = function(url, options) { | |
var opt = { | |
url: url | |
}; | |
if (options.attribution) opt.credit = options.attribution; | |
if (options.minZoom) opt.minimumLevel = options.minZoom; | |
if (options.maxZoom) opt.maximumLevel = options.maxZoom; | |
var imageryProvider = new Cesium.UrlTemplateImageryProvider(opt); | |
if (options.opacity) imageryProvider.defaultAlpha = options.opacity; | |
if (options.brightness) imageryProvider.defaultBrightness = options.brightness; | |
if (options.contrast) imageryProvider.defaultContrast = options.contrast; | |
if (options.gamma) imageryProvider.defaultGamma = options.gamma; | |
if (options.hue) imageryProvider.defaultHue = options.hue; | |
if (options.saturation) imageryProvider.defaultSaturation = options.saturation; | |
return { | |
imageryProvider: imageryProvider, | |
addTo: function(map) { | |
map.addLayer(this); | |
return this; | |
} | |
} | |
}; | |
window.CS = CS; | |
})(window); |
This file contains hidden or 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0" /> | |
<title>cesium</title> | |
<link rel="stylesheet" href="https://unpkg.com/[email protected]/Build/Cesium/Widgets/widgets.css" /> | |
<script src="https://unpkg.com/[email protected]/Build/Cesium/Cesium.js"></script> | |
<script src="cs.js"></script> | |
</head> | |
<body> | |
<div id="container" style="position:absolute;top:0;left:0;bottom:0;right:0;user-select:none;"></div> | |
<script> | |
var map = CS.map("container", { | |
terrainExaggeration: 5.0 | |
}).setView(CS.latLng(28.603885, 145.530003, 1119707), 320, -45); | |
CS.tileLayer("https://cyberjapandata.gsi.go.jp/xyz/hillshademap/{z}/{x}/{y}.png", { | |
attribution: "地理院タイル(陰影起伏図)", | |
minZoom: 2, | |
maxZoom: 18 | |
}).addTo(map); | |
CS.tileLayer("http://soil-inventory.dc.affrc.go.jp/tile/figure/{z}/{x}/{y}.png", { | |
attribution: "農研機構・日本土壌インベントリー(土壌図)", | |
minZoom: 2, | |
maxZoom: 15, | |
opacity: 0.75, | |
saturation: 1 / 0.75 | |
}).addTo(map); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment