コンテンツにスキップ

Midday over Tokyo

3D buildings of Tokyo under the midday sun

midday_tokyo_3d_buildings.html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Midday over Tokyo</title>
  <meta property="og:description" content="3D buildings of Tokyo under the midday sun" />
  <script src="./v0.10.6/mapray.min.js"></script>
  <script src="./v0.10.6/maprayui.min.js"></script>
  <link rel="stylesheet" href="./v0.10.6/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>
  const cloudApi = new mapray.cloud.CloudApiV2({
    tokenType: mapray.cloud.CloudApi.TokenType.ACCESS_TOKEN,
    token: "<YOUR_MAPRAY_ACCESS_TOKEN>"
  });

  const uiviewer = new maprayui.StandardUIViewer( "mapray-container", {
    dem_provider: new mapray.StandardDemProvider( cloudApi.getDefaultDemAsResource() ),
    atmosphere: new mapray.Atmosphere(),
    sun_visualizer: new mapray.SunVisualizer( 32 )
  } );

  // Looking at Tokyo Tower from the east.
  uiviewer.setCameraPosition({ longitude: 139.7720, latitude: 35.6520, height: 700 });
  uiviewer.setLookAtPosition({ longitude: 139.7454, latitude: 35.6586, height: 250 });

  // PLATEAU 3D buildings, published as B3D tiles on the mapray open tile server.
  // The keys are Japanese standard second-mesh codes covering central Tokyo.
  const MESH_CODES = [ "533935", "533936", "533945", "533946" ];
  for ( const code of MESH_CODES ) {
    const provider = new mapray.StandardB3dProvider( { url: `https://opentiles.mapray.com/3dcity/${code}/tile-index.json` } );
    uiviewer.viewer.b3d_collection.createScene( provider );
  }

  // Sun direction in GOCS. This one is the midday sun over Tokyo on the summer
  // solstice (2026-06-21 12:00 JST): bearing 198 deg, elevation 77 deg.
  uiviewer.viewer.sun.setSunDirection( [ -0.653770, 0.643742, 0.397719 ] );
</script>

Info

このサンプルコードは、<YOUR_MAPRAY_ACCESS_TOKEN>を、あなたのMapray CloudのアカウントのOrganization Tokenに置き換えるまで、期待通りに動作しません。