this.runned = value;
}
+ addLevel(){
+ this.LEVEL++;
+ }
+
init() {
let initMap = this.initMap;
initMap(location,map){
- map.setCenter(location,8);
+ map.setCenter(location,3);
instance.http.get(dhisAPI+'/api/organisationUnits'+query)
.map(res => res.json())
.subscribe(
- res => instance.parseResult(res),
+ res => instance.parseResult(res,instance),
error => instance.logError(error)
);
}
- parseResult(res){
- console.log(res);
+ parseResult(res,instance){
+
if(res.organisationUnits) {
for (let item in res.organisationUnits) {
this.getData('/' + res.organisationUnits[item].id,this);
}
//liten hack
- }//else if(res.name != false){
- // for (let item in res.children) {
- // this.getData('/' + res.children[item].id,this);
- //}
- //}
+ }else if(!res.displayName && res.children){
+ for (let item in res.children) {
+ if(res.children[item].level == instance.LEVEL){
+ this.getData('/' + res.children[item].id,this);
+ }
+ }
+ instance.setRunned(false);
+ }
else {
-
- this.drawPolygon(res);};
+ this.drawPolygon(res);
+ };
}
drawPolygon(item){
let instance = this;
"id": item.id
}
};
+ if(unit.geometry.type == 'Point'){
+ unit.geometry.type.);
+ }
this.map.data.addGeoJson(unit);
this.map.data.addListener('click', function(event) {
-
//TODO: spør om man vil ned/opp eller se info
if(instance.runned == false){
instance.setRunned(true);
instance.map.data.forEach(function(feature) {
instance.map.data.remove(feature);
});
+ instance.addLevel();
instance.getData('/' + id+'/children',instance);
- // instance.getData('/' + id,instance);
-
}
});