Commit 75ee91fc authored by Eric Duminil's avatar Eric Duminil
Browse files

Refresh style.

parent ec11b3d8
var regionChooser = (function(){ const styles = {};
styles.original = utils.polygon_style('#447744', 0.2);
styles.highlighted = utils.polygon_style("#ff44a2", 0.7);
styles.selected = utils.polygon_style("#ffff00", 0.8);
const regionChooser = (function(){
//TODO: Somehow split in classes. This file is getting too big and mixed //TODO: Somehow split in classes. This file is getting too big and mixed
var publicScope = {}; var publicScope = {};
const fromJavaFX = navigator.userAgent.indexOf('JavaFX') !== -1; const fromJavaFX = navigator.userAgent.indexOf('JavaFX') !== -1;
...@@ -26,7 +32,7 @@ var regionChooser = (function(){ ...@@ -26,7 +32,7 @@ var regionChooser = (function(){
var kml_layer = new ol.layer.Vector({ var kml_layer = new ol.layer.Vector({
source : kml_source, source : kml_source,
style : utils.polygon_style('#447744', 0.2) style : styles.original
}); });
var intersections = new ol.source.Vector(); var intersections = new ol.source.Vector();
...@@ -74,7 +80,7 @@ var regionChooser = (function(){ ...@@ -74,7 +80,7 @@ var regionChooser = (function(){
feature["project"] = feature.get("project"); feature["project"] = feature.get("project");
feature["name"] = feature.get("name"); feature["name"] = feature.get("name");
feature["source"] = "CityGML"; feature["source"] = "CityGML";
feature["originalStyle"] = feature.getStyle(); feature["status"] = "original";
}); });
var features = Array.from(kml_source.getFeatures()); var features = Array.from(kml_source.getFeatures());
...@@ -160,22 +166,26 @@ var regionChooser = (function(){ ...@@ -160,22 +166,26 @@ var regionChooser = (function(){
publicScope.highlightPolygon = function(i) { publicScope.highlightPolygon = function(i) {
var feature = kml_source.getFeatureById(i); var feature = kml_source.getFeatureById(i);
feature.setStyle(utils.polygon_style("#ff44a2", 0.7)); feature.setStyle(styles.highlighted);
} }
publicScope.resetHighlight = function(i) { publicScope.resetHighlight = function(i) {
var feature = kml_source.getFeatureById(i); var feature = kml_source.getFeatureById(i);
feature.setStyle(feature.originalStyle); refreshStyle(feature);
}
refreshStyle = function(feature){
feature.setStyle(styles[feature.status]);
} }
publicScope.isDownloadPossible = function(){ publicScope.isDownloadPossible = function(){
kml_source.getFeatures().forEach(f => f.setStyle(f.originalStyle)); kml_source.getFeatures().forEach(f => {f.status = "original"; refreshStyle(f)});
//TODO: Dry //TODO: Dry
var checkedBoxes = Array.from(document.querySelectorAll("input.select_citygml")).filter(c => c.checked); var checkedBoxes = Array.from(document.querySelectorAll("input.select_citygml")).filter(c => c.checked);
var checkbox_ids = checkedBoxes.map(c => c.id); var checkbox_ids = checkedBoxes.map(c => c.id);
var features = getCheckedPolygons(checkbox_ids); var features = getCheckedPolygons(checkbox_ids);
features.forEach(f => f.setStyle(utils.polygon_style("#ffff00", 0.8))); features.forEach(f => {f.status = "selected"; refreshStyle(f)});
document.getElementById("download_region_button").disabled = (checkedBoxes.length == 0); document.getElementById("download_region_button").disabled = (checkedBoxes.length == 0);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment