Hello,
I have a toggle button that i need to use for handling the map click. I have the following code but i cannot disable the map click for some reason.
I searched already in the working with events page and i dont know what im missing.
My code is:
onToggleButtonClick(e){ var map = this.props.themap; var map_click_handle; //enable the map click and get the geometry point if (this.state.toggleCliente =='OFF'){ this.setState({toggleCliente: 'ON'}); $('.factigis_btnSelectCliente').css('color',"crimson"); map_click_handle = dojo.connect(map, 'onClick', (g)=>{ console.log("My click", g); }); //disable the map click to not get the geometry point. }else{ this.setState({toggleCliente: 'OFF'}); $('.factigis_btnSelectCliente').css('color',"black"); dojo.disconnect(map_click_handle); } }
Solved! Go to Solution.
Oh i did it already adding an state for the map_click_handle:
onToggleButtonClick(e){
var map = this.props.themap;
var map_click_handle;
if (this.state.toggleCliente =='OFF'){
this.setState({toggleCliente: 'ON'});
$('.factigis_btnSelectCliente').css('color',"crimson");
map_click_handle = dojo.connect(map, 'onClick', (g)=>{
console.log("My click", g);
});
this.setState({btnCliente: map_click_handle});
}else{
this.setState({toggleCliente: 'OFF'});
$('.factigis_btnSelectCliente').css('color',"black");
dojo.disconnect(this.state.btnCliente);
}
}
Thanks anyways
Oh i did it already adding an state for the map_click_handle:
onToggleButtonClick(e){
var map = this.props.themap;
var map_click_handle;
if (this.state.toggleCliente =='OFF'){
this.setState({toggleCliente: 'ON'});
$('.factigis_btnSelectCliente').css('color',"crimson");
map_click_handle = dojo.connect(map, 'onClick', (g)=>{
console.log("My click", g);
});
this.setState({btnCliente: map_click_handle});
}else{
this.setState({toggleCliente: 'OFF'});
$('.factigis_btnSelectCliente').css('color',"black");
dojo.disconnect(this.state.btnCliente);
}
}
Thanks anyways