Function setTyphoonObjectCondition

  • 台風オブジェクトの表示条件を設定する — 詳細な使用例

    地図上に台風をベクター描画します。 TyphoonObjectConditionInitOptions で見た目・コールバックを指定し、 callbackTyphoonSetUp で台風データ(TyphoonExplanation[])を受け取ります。


    TyphoonObjectConditionInitOptions

    オプション 説明
    callbackTyphoonSetUp (list: TyphoonExplanation[]) => void 台風オブジェクト生成完了後に呼ばれるコールバック
    typhoonStyleOption 予報円・暴風円・ラベルの色などのスタイルオプション
    emphasizedStyleOption 強調表示時・非強調時のスタイルオプション

    TyphoonExplanation の主要フィールド

    フィールド 説明
    numbering number 台風の号数(例: 1→「台風1号」)
    direction string | undefined 進行方向(例: 「北北東」)
    pressure number | undefined 中心気圧(hPa)
    maxWindSpeed number | undefined 最大風速(m/s)
    peakWindSpeed number | undefined 最大瞬間風速(m/s)
    informationText string | undefined 台風の詳細テキスト

    Returns void

    Warning

    • データ取得は非同期です。台風情報の配列は callbackTyphoonSetUp で受け取ってください。
    • typhoonExplanationList が空の場合は「現在台風情報はありません」などのUIを表示してください。
    • clearTyphoonObjectCondition を呼ぶと描画済みの台風オブジェクトがすべて削除されます。

    Example: 有効化・無効化のライフサイクル(視点移動 + コールバック受取)

    import * as GIA from '@ntj/gaia';

    const TOKYO = new GIA.value.LatLng(35.681236, 139.767125);

    // --- 有効化 ---
    const show = () => {
    map.setTyphoonObjectCondition(new GIA.value.TyphoonObjectCondition({
    callbackTyphoonSetUp: (typhoonExplanationList) => {
    if (typhoonExplanationList.length === 0) {
    console.log('現在台風情報はありません');
    return;
    }
    // 台風情報を先頭から表示
    const first = typhoonExplanationList[0];
    console.log(`台風${first.numbering}号`);
    console.log(`方向: ${first.direction ?? '不明'}`);
    console.log(`気圧: ${first.pressure ?? '不明'} hPa`);
    console.log(`最大風速: ${first.maxWindSpeed ?? '不明'} m/s`);
    console.log(`最大瞬間風速: ${first.peakWindSpeed ?? '不明'} m/s`);
    console.log(first.informationText ?? '');

    // 先頭の台風を強調表示
    map.emphasizeTargetTyphoons([first]);
    },
    }));

    // 台風観測に適した俯瞰ビューへ
    map.setDirection(0);
    map.setTilt(0);
    map.setCenter(TOKYO);
    map.setZoomLevel(5, false);
    };

    // --- 無効化 ---
    const hide = () => {
    map.clearTyphoonObjectCondition();
    };

    Example: 複数台風を prev/next ボタンで切り替えて強調表示する

    import * as GIA from '@ntj/gaia';

    let typhoonList: GIA.types.TyphoonExplanation[] = [];
    let currentIndex = 0;

    map.setTyphoonObjectCondition(new GIA.value.TyphoonObjectCondition({
    callbackTyphoonSetUp: (list) => {
    typhoonList = list;
    currentIndex = 0;
    if (list.length > 0) {
    map.emphasizeTargetTyphoons([list[0]]);
    }
    },
    emphasizedStyleOption: {
    deemphasizedFadedAlphaFactor: 0.3, // 非強調の台風を薄く表示
    },
    }));

    // 前の台風へ
    const onPrev = () => {
    if (currentIndex <= 0) return;
    currentIndex--;
    map.emphasizeTargetTyphoons([typhoonList[currentIndex]]);
    };

    // 次の台風へ
    const onNext = () => {
    if (currentIndex >= typhoonList.length - 1) return;
    currentIndex++;
    map.emphasizeTargetTyphoons([typhoonList[currentIndex]]);
    };

    See