コンテンツにスキップ

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="https://resource.mapray.com/mapray-js/v0.9.6/mapray.min.js"></script>
  <script src="https://resource.mapray.com/ui/v0.9.6/maprayui.min.js"></script>
  <link rel="stylesheet" href="https://resource.mapray.com/styles/v1/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>
    // Set up your access token, which can be created in Mapray Cloud.
    var apikey= "<YOUR_MAPRAY_API_KEY>";

    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", apikey, {
        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_API_KEY>を、あなたのMapray CloudアカウントのAPI Keyに置き換えるまで、期待通りに動作しません。