]> git.uio.no Git - u/erikhf/frm.git/commitdiff
final commit
authorJulie Hill Roa <julie.hill.roa@gmail.com>
Sun, 13 Dec 2015 09:19:01 +0000 (10:19 +0100)
committerJulie Hill Roa <julie.hill.roa@gmail.com>
Sun, 13 Dec 2015 09:19:01 +0000 (10:19 +0100)
src/components/map/map.ts
src/components/sidebar/sidebar.ts

index 1e5ede4a1298d259d8e8227fb65ed46fdf44949d..b516612a53bc30a742b45a981d5dc645b4c7204c 100644 (file)
@@ -24,6 +24,7 @@ export class Map {
     isSearched:boolean;
     COLORS:Object;
     colornum:number;
+    isNew:boolean;
     //popupON:boolean;
     //popup:Object;
 
@@ -58,6 +59,7 @@ export class Map {
         this.uprunned = false;
         this.currentMarker = null;
         this.isSearched = false;
+        this.isNew = false;
         this.colornum = 0;
         this.COLORS = ['#ede1bb', '#1d407e', '#ff512e', '#662d47', '#3b3a35', '#419175', '#983e41', '#f3002d', '#b0a875', '#00bfb5', '#926851', '#47a0a4', '#333f50', '#6f007b'];
         //this.popupON = false;
@@ -320,8 +322,8 @@ export class Map {
                 });
             });
 
-            if (instance.isSearched) {
-                instance.seeDetails();
+            if (this.isSearched) {
+                this.seeDetails();
             }
             this.map.data.addListener('click', function (event) {
                 $('#myModal').modal('show');
@@ -346,7 +348,9 @@ export class Map {
                 }
             });
 
-//slette ?? §§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§
+            // a method for giving a popup with the org.units name when the mouse is over the plygon
+            //commented out because somethimes it made it harder to click on the polygon to get options
+            // to see more or drillup/down
             /*   this.map.data.addListener('mouseover', function (e) {


              if(!instance.popupON) {
              instance.popupON = true;
@@ -367,17 +371,18 @@ export class Map {
         }
     }
 
-
-///////////////////////////////////////////////////////////////////////////////////
-
+    /**
+     * utpdates the map after an org.unit has been updated or a new one has been added
+     * @param event - id of the new or updated org.unit
+     */
     updateAfterAddorEdit(event) {
-        console.log(" nå har jeg updates eller adda" + this.currentMarker);
         if (this.currentMarker) {
             this.currentMarker.setMap(null);
         }
 
         let map = this.getMap();
         let http = this.getHttp();
+        this.isNew = false;
 
 
         map.data.forEach(function (feature) {
@@ -390,12 +395,17 @@ export class Map {
             );
     }
 
+    /**
+     * shows the right level with the right org.units after one has been added or updated.
+     * @param res
+     * @param instance
+     */
     updateMap(res, instance) {
         this.isSearched = false;
         this.setLevel(res.level);
         this.setActiveId(res.id);
         this.setParent(res.parent.id);
-        this.setcurrentPos({lat: JSON.parse(res.coordinates)[1], lng: JSON.parse(res.coordinates)[0]});
+        this.setcurrentPos(new google.maps.LatLng(JSON.parse(res.coordinates)[1],JSON.parse(res.coordinates)[0]));
 
         instance.getData('/' + res.parent.id + '/children', instance);
         if (res.coordinates == null || instance.LEVEL == instance.allLevels) {
@@ -408,11 +418,11 @@ export class Map {
 
     }
 
-//////////////////////////////////////////////////////////////////////////////////////////
     /**
      * removes the polygon on current level and calles getData on one level down in the org.unit hierarchy
      */
     drillDown() {
+        this.isSearched = false;
         this.closeModal();
         let map = this.getMap();
         let id = this.activeId;
@@ -437,6 +447,7 @@ export class Map {
      *removes the plogons on the current level and calles the get data with tha parents id and set parent true. this to say that we want this parent's parent
      */
     drillUp() {
+        this.isSearched = false;
         this.setupRunned(true);
         this.upLevel();
         let instance = this;
@@ -458,7 +469,6 @@ export class Map {
      * focuses map and colors to the clicked marker/polygon and fires an event to sidebar with the id of the marker
      */
     seeDetails() {
-        console.log("KOM INN HER");
         let map = this.getMap();
         let id = this.activeId;
         this.closeModal();
@@ -468,7 +478,7 @@ export class Map {
                 if (feature.getProperty('icon') !== null) {
                     feature.O.icon.strokeColor = 'red';
                 }
-                this.isSearched = false;
+
             }
             else {
                 feature.setProperty('color', 'gray');
@@ -485,6 +495,7 @@ export class Map {
      */
     addUnit() {
         this.closeModal();
+        this.isNew = true;
         let pos = this.getcurrentPos();
         let lat = pos.lat();
         let lng = pos.lng();
@@ -558,10 +569,10 @@ export class Map {
             let position = {lat: null, lng: null};
             position.lat = Math.round(pos.lat * 10000) / 10000;
             position.lng = Math.round(pos.lng * 10000) / 10000;
-            let color = 'red';
-            if ((current.lat != position.lat) || (current.lng != position.lng)) {
-                 color = '#871F78';
-            }
+
+
+            if ((current.lat != position.lat) || (current.lng != position.lng) || this.isNew) {
+
                 let map = this.map;
                 if (this.currentMarker)
                     this.currentMarker.setMap(null);
@@ -572,13 +583,13 @@ export class Map {
                     title: 'neworg',
                     icon: {
                         path: google.maps.SymbolPath.CIRCLE,
-                        strokeColor: color,
+                        strokeColor: '#871F78',
                         scale: 4
                     }
                 });
                 this.currentMarker.setMap(map);
                 map.panTo(this.currentMarker.getPosition());
-
+            }
         }
     }
 
index 88d37ff567ca51fa35a244b079d1280dd292b9df..c959f0842eeebb8d53b6b5498a8bb3b059b63bc2 100644 (file)
@@ -110,7 +110,7 @@ export class Sidebar {
         // update the form controls with data from incoming json object
         for (control in this.form.controls) {
             if (this.form.controls[control] instanceof ControlArray) {
-                console.log("nothing to do here");
+                console.log(" ");
             }
             else if (res[control] !== undefined) {
                 this.form.controls[control].updateValue(res[control]);