1

私は自分のアプリケーションで ExtJs3.4 で geoExt を使用しています!.mapPanel を作成し、以下のコードで openlayers マップを追加します。

var mapPanel = new GeoExt.MapPanel({
        renderTo: 'gxmap',
        height: 500,
        width: 800,
        map: map,
        title: 'Map'
    });

その後、extjsトグルボタンを作成します

var button = new Ext.Button({
text: 'Measure Things',
enableToggle: true,
handler: function(toggled){
    if (toggled) {
        polygon.activate();
    } else {
        polygon.deactivate();
    }
}
});

このボタンをマップ パネルに追加したい場合、mapPanel の topPanel を取得します。その後、topPanel 関数を使用したい場合、これらの関数は機能しません。

mapPanel.getTopToolbar().addButton(button);

または以下のコード

topToolbar = mapPanel.getTopToolbar();
topToolbar.addButton(button);

クロム開発者ツールを見ると、addButton関数またはパネルのtopToolbarの他の関数でこのエラーが表示されます! エラー:

uncaught typeError: cannot call method 'addButton' of undefined

topToolbar 関数を使用できないのはなぜですか? ボタンの追加を使用してマップする
geoext のチュートリアルへのリンクmapPanel.getTToolbar().addButton(button);

4

1 に答える 1