Commit 2978d76c authored by duminil's avatar duminil
Browse files

Fixed Javascript race condition.

parent c104f778
...@@ -117,8 +117,11 @@ var map = new ol.Map({ ...@@ -117,8 +117,11 @@ var map = new ol.Map({
var geoJSONformat = new ol.format.GeoJSON(); var geoJSONformat = new ol.format.GeoJSON();
kml_layer.addEventListener("change", function(event) { kml_layer.addEventListener("change", function(event) {
var fromJavaFX = (typeof fxapp !== 'undefined');
map.getView().fitExtent(kml_source.getExtent(), (map.getSize())); map.getView().fitExtent(kml_source.getExtent(), (map.getSize()));
});
function updateGMLPolygons(){
var fromJavaFX = (typeof fxapp !== 'undefined');
kml_source.forEachFeature(function(feature) { kml_source.forEachFeature(function(feature) {
feature["geoJSON"] = geoJSONformat.writeFeatureObject(feature); feature["geoJSON"] = geoJSONformat.writeFeatureObject(feature);
feature["area"] = feature.getGeometry().getArea(); feature["area"] = feature.getGeometry().getArea();
...@@ -131,7 +134,7 @@ kml_layer.addEventListener("change", function(event) { ...@@ -131,7 +134,7 @@ kml_layer.addEventListener("change", function(event) {
} }
feature["available"] = citygmlHere; feature["available"] = citygmlHere;
}); });
}); }
// The features are not added to a regular vector layer/source, // The features are not added to a regular vector layer/source,
// but to a feature overlay which holds a collection of features. // but to a feature overlay which holds a collection of features.
...@@ -185,6 +188,7 @@ var sketch; ...@@ -185,6 +188,7 @@ var sketch;
draw.on('drawstart', function(evt) { draw.on('drawstart', function(evt) {
sketch = evt.feature; sketch = evt.feature;
reset_btn.disabled = false; reset_btn.disabled = false;
updateGMLPolygons();
}); });
var sourceProj = map.getView().getProjection(); var sourceProj = map.getView().getProjection();
......
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