1
0
Fork 0

added function to change size and color of existing airports

This commit is contained in:
Heiko Kernbach 2015-04-20 12:20:49 +02:00
parent a27953cf3b
commit 8fca525adf
1 changed files with 40 additions and 5 deletions

View File

@ -46,6 +46,8 @@
'rgb(102,37,6)' 'rgb(102,37,6)'
], ],
imageData: [],
keyToLongLat: {}, keyToLongLat: {},
//QUERIES SECTION //QUERIES SECTION
@ -93,8 +95,8 @@
airport = model.toJSON(); airport = model.toJSON();
airports.push(airport); airports.push(airport);
}); });
var preparedData = this.prepareData(airports); this.imageData = this.prepareData(airports);
this.renderMap(preparedData); this.renderMap();
// this.renderDummy(); // this.renderDummy();
}.bind(this); }.bind(this);
@ -185,6 +187,7 @@
calculateFlightWidth: function(length, pos) { calculateFlightWidth: function(length, pos) {
var intervallWidth = length/2; var intervallWidth = length/2;
// return Math.floor(pos/intervallWidth) + 2; // return Math.floor(pos/intervallWidth) + 2;
//TODO: no custom width for lines wanted?
return 1.5; return 1.5;
}, },
@ -193,6 +196,38 @@
return this.lineColors[Math.floor(pos/intervallColor)]; return this.lineColors[Math.floor(pos/intervallColor)];
}, },
//Color = HEXCODE e.g. #FFFFFF
setAirportColor: function(id, color) {
var changedColor = false;
_.each(this.imageData, function(airport) {
if (airport.id === id) {
changedColor = true;
airport.color = color;
}
});
if (changedColor) {
this.map.validateData();
}
},
//size = numeric value e.g. 0.5 or 1.3
setAirportSize: function(id, size) {
var changedSize = false;
_.each(this.imageData, function(airport) {
if (airport.id === id) {
changedSize = true;
airport.scale = size;
}
});
if (changedSize) {
this.map.validateData();
}
},
prepareData: function (data) { prepareData: function (data) {
var self = this, imageData = []; var self = this, imageData = [];
@ -205,7 +240,7 @@
svgPath: self.MAPtarget, svgPath: self.MAPtarget,
color: "#222222", color: "#222222",
scale: 0.5, scale: 0.5,
selectedScale: 2.5, selectedScale: 2.5,
title: airport.City + " [" + airport._key + "]<br>" + airport.Name, title: airport.City + " [" + airport._key + "]<br>" + airport.Name,
rollOverColor: "#ff8f35", rollOverColor: "#ff8f35",
}); });
@ -240,7 +275,7 @@
}; };
}, },
renderMap: function(imageData) { renderMap: function() {
var self = this; var self = this;
self.lines = []; self.lines = [];
@ -254,7 +289,7 @@
dataProvider: { dataProvider: {
map: "usa2High", map: "usa2High",
lines: self.lines, lines: self.lines,
images: imageData, images: self.imageData,
getAreasFromMap: true getAreasFromMap: true
}, },
clickMapObject: function(mapObject) { clickMapObject: function(mapObject) {