javascript - Is it possible to call two functions if ext.form.checkbox is checked? Or why my layers in openlayers won't re-order (both problems are linked) -
i have ext checkbox add layer on openlayers map. when layer added map.addlayer, appears @ end (on top) of layers (we can see in layerswitcher). want re-order them after create new layer. problem coming checkbox. launch function when checked, map won't added until function has ended (i don't know why). when add line re-order maps @ end of function, doesn't re-order maps @ (it seems because same still not created while inside function).
this code of checkbox:
new ext.form.checkbox({ title: extjs_gui_products_analyses_checkbox_title, id: 'analyses_checkbox_extjs', boxlabel: extjs_gui_products_analyses_checkbox_label, inputvalue: extjs_gui_products_analyses_checkbox_label, listeners: { check: addanalyselayer // reordergmllayersontop } })
i thought add line re-order in function then, , call after? made function named reordergmllayersontop , tried add check: reordergmllayersontop
. it's not working (it crashes), suppose synthax wrong. checked ext manual , never says can call 2 functions. there way call 2 functions? , if yes, syntax so?
if not, have idea re-order layers after checkbox checked?
this code function add layer
function addanalyselayer(checkbox, checked){ if(checked){ ext.ajax.request({ url: './php/wms_validator.php', params: { product: "analyse", timechop: timechoparray[currentstateindex], date: currentstatedate.getutcfullyear() + ('0' + (currentstatedate.getutcmonth() + 1)).slice(-2) + ('0' + currentstatedate.getutcdate()).slice(-2), type: currentstateperiod }, method: 'get', success: function(result, request) { if (result.responsetext != "invalid") { map.addlayer(new openlayers.layer.wms(openlayers_wms_layer_analyses, cmcdataserver, { layers: analyseswmslayer[currentstateperiod], styles: analyseswmsstyle[currentstateperiod], format: "image/png", transparent: true, time: currentstatedate.getutcfullyear() + "-" + ('0' + (currentstatedate.getutcmonth() + 1)).slice(-2) + "-" + ('0' + currentstatedate.getutcdate()).slice(-2) + "t" + timechoparray[currentstateindex] + ":00:00z" }, { opacity: opacitylevelanalyses, visibility: true })); ext.getcmp('analyses_validity_display_extjs').setvalue(extjs_gui_state_panel_valid_analyses); ext.getcmp('extjs_gui_legend_tab_panels').setactivetab(0); } else { //this user request insure users don't wait observation data doesn't exist ext.getcmp('analyses_validity_display_extjs').setvalue(extjs_gui_state_panel_invalid_analyses); ext.msg.alert(extjs_gui_analyses_missing_warning_title, extjs_gui_analyses_missing_warning); ext.getcmp('analyses_checkbox_extjs').setvalue(false); } } }); }else if(map.getlayersbyname(openlayers_wms_layer_analyses).length!=0){ adjuststatepanelanalysesvalidity(); map.removelayer(map.getlayersbyname(openlayers_wms_layer_analyses)[0]); } adjuststatepanelproducts(checkbox, checked); //my test map.raiselayer(map.getlayersbyname(openlayers_gml_layer_canada_bv)[0], map.getnumlayers()-1); }
you can see //my test
near end of code. tried, it's not re-ordering layers @ all. still, if type in console, re-orders layers want (well re-orders 1 layer, if works i'll mod have want).
so, have idea? can't seem find solution myself.
thanks anyway guys help.
update:
i tried change order toggle function of other layer, code after changes
function togglecanadabv(){ if(map.getlayersbyname(openlayers_gml_layer_canada_bv)[0].getvisibility()){ map.getlayersbyname(openlayers_gml_layer_canada_bv)[0].setvisibility(false); }else{ map.getlayersbyname(openlayers_gml_layer_canada_bv)[0].setvisibility(true); map.setlayerindex(map.getlayersbyname(openlayers_gml_layer_canada_bv)[0], 700); map.raiselayer(map.getlayersbyname(openlayers_gml_layer_canada_bv)[0], map.getnumlayers()-1); } }
but it's still not doing want @ all... don't understand.
i tried check layer (that add in function) @ end of function, , it's undefined if add in function...
finally, tried place button trigger function, , works. function correct when launched outside checkbox or toggles...
finally, have no idea why not re-order "other" layer, found solution @ least.
i added map.raiselayer(map.getlayersbyname(openlayers_wms_layer_analyses)[0], -map.getnumlayers());
after add layer, create layer @ start of index order. way, else on top. if have similar problem, hope guys.
Comments
Post a Comment