PDA

View Full Version : mapPanel topToolbar functions doesn't works



tah_206207
29 Jul 2012, 3:13 AM
I use geoExt with ExtJs3.4 in my application!.I create a mapPanel and add openlayers map into it with below code.



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


after that i create extjs toggle button



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


when i want to add this button to map panel i get topPanel of mapPanel and after that when i want to use topPanel functions these functions doesn't works!



mapPanel.getTopToolbar().addButton(button);


or below code



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


when i see chrome developer tool i see this error for addButton function or other functions of topToolbar of panel! error:


uncaught typeError: cannot call method 'addButton' of undefined

why i can't use topToolbar functions?
Link for tutorial of geoext that use mapPanel.getTToolbar().addButton(button);
http://geoext.org/tutorials/control-button-tutorial.html#extjs-buttons

sword-it
29 Jul 2012, 10:12 PM
when i want to add this button to map panel i get topPanel of mapPanel and after that when i want to use topPanel functions these functions doesn't works!
mapPanel.getTToolbar().addButton(button);
or below code
topToolbar = mapPanel.getTToolbar();





HI!
i guess, you are using wrong code to get toptoolbar
it must be,



mapPanel.getTopToolbar().addButton(button);

tah_206207
30 Jul 2012, 11:31 AM
Excuse me! this is type error
i use mapPanel.getTopToolbar().addButton(button); but when i want to use getTopToolbar() functions doesn't work!
chrome shows Error for getTopToolbar() functions!