Skip to content

Commit

Permalink
issue about showing latest flood in map:
Browse files Browse the repository at this point in the history
- show latest flood as default. inasafe/inasafe-realtime#42
- add stroke color for hazard style. inasafe/inasafe-realtime#48
  • Loading branch information
lucernae committed Feb 7, 2017
1 parent 61dcc7c commit 958e6ca
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
28 changes: 23 additions & 5 deletions django_project/realtime/static/realtime/js/flood/flood.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,22 +91,30 @@ function createShowFeaturesHandler(event_features_url){
}
var style_classes = {
1: {
color: "#bdc5f7",
stroke: true,
color: "#000",
weight: 2,
fillColor: "#bdc5f7",
fillOpacity: 0.8
},
2: {
color: "#fffe73",
stroke: true,
color: "#000",
weight: 2,
fillColor: "#fffe73",
fillOpacity: 0.8
},
3: {
color: "#fea865",
stroke: true,
color: "#000",
weight: 2,
fillColor: "#fea865",
fillOpacity: 0.8
},
4: {
color: "#da6c7b",
stroke: true,
color: "#000",
weight: 2,
fillColor: "#da6c7b",
fillOpacity: 0.8
}
Expand All @@ -115,6 +123,16 @@ function createShowFeaturesHandler(event_features_url){
style: function(feature){
return style_classes[feature.properties.hazard_data];
},
filter: function(feature){
if(feature.properties){
var props = feature.properties;
var hazard_data = props.hazard_data;
return hazard_data >= 1;
}
else {
return false;
}
},
onEachFeature: function(feature, layer) {
// Set popup content
if (feature.properties) {
Expand All @@ -134,7 +152,7 @@ function createShowFeaturesHandler(event_features_url){
scrollTop: $("#"+map_id).offset().top
}, 500);
var fitBoundsOption = {
maxZoom: 10,
maxZoom: 15,
pan: {
animate: true,
duration: 0.5
Expand Down
6 changes: 6 additions & 0 deletions django_project/realtime/templates/realtime/flood/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ <h3 class="panel-title">{% trans "Flood" %}</h3>
dynatable.paginationPerPage.set(100);
dynatable.sorts.add('time', -1);
dynatable.process();

// programatically show first flood in row
if(jsonTableContents.length > 0) {
var flood_id = jsonTableContents[0].event_id;
showFeaturesHandler(flood_id);
}
}

// Create handler for table
Expand Down

0 comments on commit 958e6ca

Please sign in to comment.