clearContextMenu でコンテキストメニューを完全に削除できます。ContextMenuItem[])です。オブジェクト形式は誤りです。text / onselect です。label / onClick は存在しません。onselect の引数 e から e.position で LatLng を取得してください。import * as GIA from '@ntj/gaia';
map.setContextMenu(new GIA.value.ContextMenu([
{
text: 'ここを中心に表示',
onselect(e) {
map.setCenter(e.position);
},
},
{
text: 'この位置をコピー',
onselect(e) {
navigator.clipboard.writeText(`${e.position.lat},${e.position.lng}`);
},
},
]));
// 後から削除
map.clearContextMenu();
コンテキストメニューを設定する — 詳細な使用例
地図上で右クリック(または長押し)したときに表示されるコンテキストメニューを設定します。
new GIA.value.ContextMenu(items, options?)でインスタンスを作成しsetContextMenuに渡します。clearContextMenuでコンテキストメニューを削除できます。ContextMenuItemtextstringonselect(e: ContextMenuEvent) => voidContextMenuEventのフィールド:e.position— クリックした地点のLatLnge.native— 元のMouseEventContextMenuOptions(第2引数・任意)hideWhenZoomChangebooleantrue