使ってみる
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
このチュートリアルでは、Maps JavaScript の Photorealistic 3D Maps を使用して最初の JavaScript アプリケーションを作成する手順を説明します。このウィンドウは、マリンヘッドランズを背景に、ゴールデン ゲート ブリッジの俯瞰ビューを表示する基本的なウィンドウです。
チュートリアルを完了すると、開発環境に次の地図が表示されます。
環境をセットアップする
コードの記述を開始する前に、JavaScript を実行する環境をセットアップする必要があります。このチュートリアルでは、環境としてウェブブラウザを使用します。最新のウェブブラウザはすべて JavaScript をサポートしているため、追加のソフトウェアをインストールする必要はありません。
- お好みのテキスト エディタを開きます。
- 新しいファイルを作成して、拡張子を
.html
(例: hello-p3djs.html
)にして保存します。
HTML ページを記述する
まず、ウェブページを基本的な HTML 構造で作成します。
<!DOCTYPE html>
<html>
<head>
<title>Hello Photorealistic 3D Maps in Maps JavaScript</title>
</head>
<body>
<!-- Your JavaScript code will go here -->
</body>
</html>
JavaScript を追加する
次に、地図を読み込むためのカスタム HTML 要素を追加します。このコードには、次の 2 つの要素が含まれています。
gmp-map-3d
。カメラの開始位置とビューを初期化するために使用するパラメータが含まれています。
script
。Maps JavaScript API を読み込む呼び出しが含まれています。YOUR_KEY
は、実際の API キーに置き換えてください。
<!DOCTYPE html>
<html>
<head>
<title>Hello Photorealistic 3D Maps in Maps JavaScript</title>
<style>
html,
body {
height:100%;
margin: 0;
padding: 0;
}
</style>
</head>
<body>
<gmp-map-3d mode="hybrid" center="37.841157, -122.551679" range="2000" tilt="75" heading="330"></gmp-map-3d>
<script async src="https://maps.googleapis.com/maps/api/js?key=<YOUR_KEY>&v=beta&libraries=maps3d"></script>
</body>
</html>
アプリケーションを実行する
アプリケーションを実行して出力を確認する手順は次のとおりです。
- 作成した HTML ファイルを保存します。
- ファイルをウェブブラウザで開きます(ファイルをダブルクリックするか、ブラウザ ウィンドウにドラッグするか、右クリックして [このアプリケーションで開く] を使用します)。
- ブラウザ ウィンドウに地図が表示されます。
これで、Maps JavaScript API で Google の Photorealistic 3D Maps を使用するアプリケーションを作成しました。
次のステップ
- Google の既存のサンプルを使用して、より複雑な 3D 地図を構築する。
- リファレンス ドキュメントをお読みになり、Maps JavaScript API の Photorealistic 3D マップを最大限に活用してください。
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-04-29 UTC。
[null,null,["最終更新日 2025-04-29 UTC。"],[],[],null,["\u003cbr /\u003e\n\n| This product or feature is in Preview (pre-GA). Pre-GA products and features might have limited support, and changes to pre-GA products and features might not be compatible with other pre-GA versions. Pre-GA Offerings are covered by the [Google\n| Maps Platform Service Specific Terms](https://cloud.google.com/maps-platform/terms/maps-service-terms). For more information, see the [launch stage\n| descriptions](/maps/launch-stages).\n\n\u003cbr /\u003e\n\nSelect platform: [Android](/maps/documentation/maps-3d/android-sdk/add-a-3d-map \"View this page for the Android platform docs.\") [iOS](/maps/documentation/maps-3d/ios-sdk/add-a-3d-map \"View this page for the iOS platform docs.\") [JavaScript](/maps/documentation/javascript/3d/get-started \"View this page for the JavaScript platform docs.\")\n\n\u003cbr /\u003e\n\nIn this tutorial, you'll guide yourself through creating your first JavaScript\napplication using Photorealistic 3D Maps in Maps JavaScript: a basic window that displays\nan overhead view of the Golden Gate Bridge with the Marin Headlands in the\nbackground.\n\nUpon completing the tutorial, you should see the following map in your\ndevelopment environment:\n\nSet up your environment\n\nBefore you begin writing code, you must set up an environment that runs\nJavaScript. For this tutorial, you'll use a web browser as your environment. All\nmodern web browsers have built-in support for JavaScript, so you don't need to\ninstall any additional software.\n\n1. Open a text editor of your choosing.\n2. Create a new file and save it with an `.html` extension (e.g., `hello-p3djs.html`).\n\nWrite an HTML page\n\nTo start, you'll create a web page with a basic HTML structure: \n\n \u003c!DOCTYPE html\u003e\n \u003chtml\u003e\n \u003chead\u003e\n \u003ctitle\u003eHello Photorealistic 3D Maps in Maps JavaScript\u003c/title\u003e\n \u003c/head\u003e\n \u003cbody\u003e\n \u003c!-- Your JavaScript code will go here --\u003e\n \u003c/body\u003e\n \u003c/html\u003e\n\nAdd JavaScript\n\nNext, you'll add a custom HTML element to load the map. The code contains two\nelements:\n\n- `gmp-map-3d` contains the parameters used for initializing the starting camera position and view.\n- `script` contains the call to load the Maps JavaScript API. Be sure to replace `YOUR_KEY` with your API key.\n\n \u003c!DOCTYPE html\u003e\n \u003chtml\u003e\n \u003chead\u003e\n \u003ctitle\u003eHello Photorealistic 3D Maps in Maps JavaScript\u003c/title\u003e\n\n \u003cstyle\u003e\n html,\n body {\n height:100%;\n margin: 0;\n padding: 0;\n }\n \u003c/style\u003e\n \u003c/head\u003e\n \u003cbody\u003e\n \u003cgmp-map-3d mode=\"hybrid\" center=\"37.841157, -122.551679\" range=\"2000\" tilt=\"75\" heading=\"330\"\u003e\u003c/gmp-map-3d\u003e\n \u003cscript async src=\"https://maps.googleapis.com/maps/api/js?key=\u003cYOUR_KEY\u003e&v=beta&libraries=maps3d\"\u003e\u003c/script\u003e\n \u003c/body\u003e\n \u003c/html\u003e\n\nRun the application\n\nTo run the application and see the output, follow these steps:\n\n1. Save the HTML file you created.\n2. Open the file in a web browser (you can double-click the file, drag it into a browser window, or right-click and use \"Open with\").\n3. You should see the map in your browser window.\n\nCongratulations! You've just written an application using Google's\nPhotorealistic 3D Maps in Maps JavaScript API.\n\nNext steps\n\n- Build more complicated 3D map experiences using Google's existing [samples](/maps/documentation/javascript/examples/3d/simple-map).\n- Discover the full potential of the Photorealistic 3D Maps in Maps JavaScript API by reading the [reference documentation](/maps/documentation/javascript/reference/3d-map)."]]