コンテンツにスキップ

Add a raster tile source

Add a third-party raster source to the map.

add_raster_tile_source.html
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>Add a raster tile source</title>
        <meta property="og:description" content="Add a third-party raster source to the map." />
        <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>
    const cloudApi = new mapray.cloud.CloudApiV2({
        tokenType: mapray.cloud.CloudApi.TokenType.ACCESS_TOKEN,
        token: "<YOUR_MAPRAY_ACCESS_TOKEN>"
    });

    const imageProvider = new mapray.StandardImageProvider( {
        url: "https://cyberjapandata.gsi.go.jp/xyz/std/",
        format: ".png",
        min_level: 0,
        max_level: 18
    } );
    // 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() ),
        image_provider: imageProvider
    } );


    uiviewer.setCameraPosition({
    longitude: 138.73133611,
    latitude: 35.35990555,
    height: 5000000
  });

  uiviewer.setLookAtPosition({
    longitude: 138.73133611,
    latitude:  35.35990555,
    height: 3776
  });

</script>

Info

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