Retour à la documentation
/**
* @class spw.widgets.SpwHeatAndCluster
*/
define(["dojo/_base/declare", "spw/api/SpwBaseTemplatedWidget", "dojo/text!./templates/SpwHeatAndCluster.html",
"dojo/i18n!./nls/SpwHeatAndCluster","dojo/dom-style", "dojo/on", "dojo/dom-construct", "dojo/_base/lang",
"dojo/_base/array","dijit/form/CheckBox","dijit/registry"],
function(declare, SpwBaseTemplatedWidget, tmpl,
labels,domStyle, on, domConstruct, lang,
array,CheckBox,registry) {
return declare("spw.widgets.SpwHeatAndCluster", [SpwBaseTemplatedWidget], /** @lends spw.widgets.SpwHeatAndCluster.prototype */{
templateString: tmpl,
labels: labels,
/**
* @constructs
* @param config
*/
constructor: function() {
},
postCreate: function(){
this.inherited(arguments);
if(this.mapServices && this.mapServices.length > 0){
array.forEach(this.mapServices, function(mapService){
if(typeof(mapService.checked)==="undefined"){
mapService.checked = false;
}
});
}
},
onActivate: function(){
this.inherited(arguments);
domConstruct.empty(this.heatAndClusterDiv.id);
if(this.mapServices && this.mapServices.length > 0){
var table = domConstruct.create("table");
domConstruct.place(table,this.heatAndClusterDiv);
array.forEach(this.mapServices, lang.hitch(this,function(mapService,index){
if(registry.byId("checkbox_heatAndCluster"+index))
registry.byId("checkbox_heatAndCluster"+index).destroy();
var tr = domConstruct.create("tr");
domConstruct.place(tr,table);
var td_cb = domConstruct.create("td",{"id":"checkbox_heatAndCluster"+index});
domConstruct.place(td_cb,tr);
var td_label = domConstruct.create("td",{"innerHTML":mapService.label});
domConstruct.place(td_label,tr);
new CheckBox({
checked: mapService.checked,
onChange: lang.hitch(this,function(checked){
if(checked){
mapService.checked = true;
this.spwViewer.get('spwMap').addMapService(mapService);
}
else{
mapService.checked = false;
this.spwViewer.get('spwMap').removeMapService(mapService.serviceId);
}
})
}, "checkbox_heatAndCluster"+index).startup();
if(mapService.checked){
this.spwViewer.get('spwMap').addMapService(mapService);
}
}));
}
else{
this.heatAndClusterDiv.innerHTML = this.labels.noServicesLabel;
}
},
onDeactivate: function(){
this.inherited(arguments);
array.forEach(this.mapServices, lang.hitch(this,function(mapService){
if(mapService.checked)
this.spwViewer.get('spwMap').removeMapService(mapService.serviceId);
}));
}
});
});