Display 3D Building on the earth with Mapray Cloud¶
Displays 3D building data uploaded to Mapray Cloud on the earth
display_3d_building_with_mapraycloud.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Display 3D Building on the earth with Mapray Cloud</title>
<meta property="og:description" content="Displays 3D building data uploaded to Mapray Cloud on the earth " />
<script src="./v0.10.1/mapray.min.js"></script>
<script src="./v0.10.1/maprayui.min.js"></script>
<link rel="stylesheet" href="./v0.10.1/mapray.css">
<style>
body {margin: 0; padding: 0;}
html, body, div#mapray-container { height: 100%; }
</style>
</head>
<body>
<div id="mapray-container"></div>
</body>
</html>
<script>
async function main() {
// Set up your access token, which can be created in Mapray Cloud.
const cloudApi = new mapray.cloud.CloudApiV2({
tokenType: mapray.cloud.CloudApi.TokenType.ACCESS_TOKEN,
token: "<YOUR_MAPRAY_ACCESS_TOKEN>"
});
// The StandardUIView in the ui package includes mouse-based camera manipulation.
const uiviewer = new maprayui.StandardUIViewer( "mapray-container", {
dem_provider: new mapray.StandardDemProvider( cloudApi.getDefaultDemAsResource() )
} );
await uiviewer.viewer.init_promise;
// Load the geojson with all features.
const datasetId = "5090888661336064";
const resource = cloudApi.getB3dDatasetAsResource( datasetId );
// Load the data using GeoJSONLoader.
const provider = new mapray.StandardB3dProvider( resource );
const b3dScene = uiviewer.viewer.b3d_collection.createScene( provider );
uiviewer.setCameraPosition({
longitude: 139.560079,
latitude: 35.68,
height: 300
});
uiviewer.setLookAtPosition({
longitude: 139.560079,
latitude: 35.708047,
height: 0
});
}
main();
</script>
Info
このサンプルコードは、<YOUR_MAPRAY_ACCESS_TOKEN>を、あなたのMapray CloudアカウントのOrganization Tokenに置き換えるまで、期待通りに動作しません。