}
+ getMap(){
+ return this.map;
+ }
+
+ getHttp(){
+ return this.http;
+ }
setcurrentPos(latlng){
this.currentPos = latlng;
}
}
drawPolygon(item, instance){
+ let bounds = new google.maps.LatLngBounds();
let feature;
let incoming: string;
incoming = item.featureType.toLowerCase();
}
this.map.data.addGeoJson(unit);
- this.map.data.addListener('click', function(event) {
- //TODO: spør om man vil ned/opp eller se info
- //TODO: finne liste over alle levels slike at man ikke har hardkodet inn < 4 !!
+ this.map.data.addListener('click', function (event) {
+ //TODO: spør om man vil ned/opp eller se info
+ //TODO: finne liste over alle levels slike at man ikke har hardkodet inn < 4 !!
- console.log(instance.LEVEL);
+ console.log(instance.LEVEL);
- if(instance.runned == false && instance.LEVEL < 4 ){
- instance.setRunned(true);
+ if (instance.runned == false && instance.LEVEL < 4) {
+ instance.setRunned(true);
- let infowindow = new google.maps.InfoWindow({
- //TODO: Style this
- content:'<div> <button >DrillUP</button>' +
- ' <button ">DrillDOWN</button>' +
- '<button ">SEEINFO</button></div>'
- });
+ let infowindow = new google.maps.InfoWindow({
+ //TODO: Style this
+ content: '<div> <button >DrillUP</button>' +
+ ' <button ">DrillDOWN</button>' +
+ '<button ">SEEINFO</button></div>'
+ });
- infowindow.setPosition(event.latlng);
- // infowindow.open(instance.map);
+ infowindow.setPosition(event.latlng);
+ // infowindow.open(instance.map);
- let id = event.feature.O.id;
- instance.setParent(id);
- console.log(id);
+ let id = event.feature.O.id;
+ instance.setParent(id);
+ console.log(id);
- instance.map.data.forEach(function(feature) {
- instance.map.data.remove(feature);
- });
+ instance.map.data.forEach(function (feature) {
+ instance.map.data.remove(feature);
+ });
- instance.addLevel();
- instance.getData('/' + id+'/children',instance);
- }else if(instance.runned == false && instance.LEVEL >= 4){
+ instance.addLevel();
+ instance.getData('/' + id + '/children', instance);
+ } else if (instance.runned == false && instance.LEVEL >= 4) {
instance.setRunned(true);
- let infowindowNew = new google.maps.InfoWindow({
- //TODO: Style this
- content:'<div>Du you want to add a new OrgUnit here ? <button onclick="myFunction()">Yes</button></div>'
- });
- instance.setcurrentPos(event.latLng);
+ let infowindowNew = new google.maps.InfoWindow({
+ //TODO: Style this
+ content: '<div>Du you want to add a new OrgUnit here ? <button onclick="myFunction()">Yes</button></div>'
+ });
+ instance.setcurrentPos(event.latLng);
- var marker = new google.maps.Marker({
- position: event.latLng,
- map: instance.map,
- title: 'newOrg',
- icon: {
- path: google.maps.SymbolPath.CIRCLE,
- scale: 5
- }
+ var marker = new google.maps.Marker({
+ position: event.latLng,
+ map: instance.map,
+ title: 'newOrg',
+ icon: {
+ path: google.maps.SymbolPath.CIRCLE,
+ scale: 5
+ }
- });
+ });
- marker.setMap(instance.map);
+ marker.setMap(instance.map);
- infowindowNew.open(instance.map, marker);
+ infowindowNew.open(instance.map, marker);
- infowindowNew.addListener('closeclick', function (e) {
- marker.setMap(null);
- });
+ infowindowNew.addListener('closeclick', function (e) {
+ marker.setMap(null);
+ });
- instance.addUnit();
+ instance.addUnit();
- }
+ }
+
+
+ });
- });
this.map.data.addListener('rightclick', function(event) {
if(instance.uprunned == false) {
console.log("Inne i myfunksjonen");
}
+
update(event){
this.newactive.next(event);
+
+ let test = this.getMap();
+ let http = this.getHttp();
+
+ test.data.forEach(function (feature) {
+ test.data.remove(feature);
+ });
+ http.get(dhisAPI+'/api/organisationUnits/'+event)
+ .map(res => res.json())
+ .subscribe(
+ res => this.drawPolygon(res,test)
+
+ );
+
+
+
}
}