地図での操作
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
リッスンしてプログラマティックに処理できるユーザー インターフェース イベントとエラー イベントについて説明します。
ユーザー インターフェース イベント
このセクションでは、3D 地図での操作をプログラマティックにリッスンして処理できるインタラクティブなイベントと状態変更通知の概要を説明します。ブラウザ内の JavaScript は「イベント駆動型」です。つまり、プログラムがリッスンしそれに応じてコードを実行するイベントを生成することでユーザー操作に応答します。
イベントには、主に以下の 2 つのタイプがあります。
- ユーザー操作イベント(マウスのクリックなど)。3D 地図のビューポートからコードに伝播されます。このイベントにより、3D 地図環境内でユーザーの直接的なアクションに応答できます。サンプルを表示
- 状態変更通知。基盤となる 3D 地図データモデルとレンダリング状態の更新が反映されます。その際には、従来の
gmp-propertychange
命名規則が使用されます。
各 3D マッピング API オブジェクトは、一連の名前付きイベントを公開します。これらの名前付きイベントは、プログラムでイベント リスナーを登録し、それらのイベントが発生したときに、組み込みの addEventListener()
関数を使用してロジックを実行できます。
次のサンプルは、ユーザーが地図を操作したときにトリガーされるイベントを示しています。
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 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\nThis page describes the user interface events and error events that you can\nlisten for and handle programmatically.\n\nUser Interface Events\n\nThis section outlines the interactive events and state change notifications you\ncan listen for and handle programmatically when working with 3D maps. JavaScript\nwithin the browser is event-driven, meaning it responds to user interactions by\ngenerating events that your program can listen to and execute code accordingly.\n\nThere are two main types of events:\n\n- User interaction events (such as mouse clicks) are propagated from the 3D map viewport to your code. These events allow you to respond to direct user actions within the 3D map environment. [View\n sample](/maps/documentation/javascript/examples/3d/polygon-click-event).\n- State change notifications reflect updates to the underlying 3D map data models and rendering state, using a conventional `gmp-propertychange` naming scheme.\n\nEach 3D mapping API object exposes a set of named events that your program can\nregister event listeners for and execute logic when those events occur using the\nbuilt-in `addEventListener()` function.\n\nThe following sample shows which events are triggered as a user interacts with\nthe map:"]]