isSearched:boolean;
COLORS:Object;
colornum:number;
+ isNew:boolean;
//popupON:boolean;
//popup:Object;
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;
});
});
- if (instance.isSearched) {
- instance.seeDetails();
+ if (this.isSearched) {
+ this.seeDetails();
}
this.map.data.addListener('click', function (event) {
$('#myModal').modal('show');
}
});
-//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;
}
}
-
-///////////////////////////////////////////////////////////////////////////////////
-
+ /**
+ * 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) {
);
}
+ /**
+ * 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) {
}
-//////////////////////////////////////////////////////////////////////////////////////////
/**
* 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;
*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;
* 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();
if (feature.getProperty('icon') !== null) {
feature.O.icon.strokeColor = 'red';
}
- this.isSearched = false;
+
}
else {
feature.setProperty('color', 'gray');
*/
addUnit() {
this.closeModal();
+ this.isNew = true;
let pos = this.getcurrentPos();
let lat = pos.lat();
let lng = pos.lng();
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);
title: 'neworg',
icon: {
path: google.maps.SymbolPath.CIRCLE,
- strokeColor: color,
+ strokeColor: '#871F78',
scale: 4
}
});
this.currentMarker.setMap(map);
map.panTo(this.currentMarker.getPosition());
-
+ }
}
}