Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 27 additions & 7 deletions app/scripts/mapctrl.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@ angular.module('taarifaWaterpointsApp')
$scope.hoverText = ""
$scope.choroChoice = "percFun"

map = null
osmLayer = L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
attribution: '(c) OpenStreetMap'
)

satLayer = L.tileLayer('http://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}',
attribution: '(c) Esri'
)

regionLayer = null
districtLayer = null
wardLayer = null

# FIXME: "ward" and "region" should be defined elsewhere I think
getFeaturedItem = (feature) ->
res = {}
Expand Down Expand Up @@ -115,13 +128,6 @@ angular.module('taarifaWaterpointsApp')
##############
### LAYERS ###
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Niggle, this section "header" no longer really reflects the contents. Worth rewording/rejigging slightly?

##############
osmLayer = L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
attribution: '(c) OpenStreetMap'
)

satLayer = L.tileLayer('http://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}',
attribution: '(c) Esri'
)

categoryMap =
"functional" : 0
Expand Down Expand Up @@ -239,4 +245,18 @@ angular.module('taarifaWaterpointsApp')
# Initialise the map
initMap([], new L.LatLng(-6.3153, 35.15625))
modalSpinner.close()

$scope.$on "dashMapReset", (event) ->
modalSpinner.open()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have not tested this (so could be wrong!) but my suspicion is that the code here executes fast enough that the spinner would just flash and disappear immediately (or display for its minimum time). In that case I would leave it out.

if map?
if map.hasLayer osmLayer
map.removeLayer osmLayer
map.addLayer satLayer
map.setView(new L.LatLng(-6.3153, 35.15625), 5)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These coordinates are listed twice in this file and are also listed at least once somewhere else (services.coffee). For now I can live with it but in an ideal world the national dashboard should use the map factory from services instead of define its own. That would solve the fundamental problem.

map.removeLayer districtLayer if map.hasLayer districtLayer
map.removeLayer wardLayer if map.hasLayer wardLayer
map.addLayer regionLayer unless map.hasLayer regionLayer
$scope.choroChoice = "percFun"
modalSpinner.close()

)
8 changes: 8 additions & 0 deletions app/scripts/natdashboardctrl.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,14 @@ angular.module('taarifaWaterpointsApp')
# access object to the population data
# FIXME: better handled by a $resource perhaps?
popData = null

$scope.reset = () ->
$scope.statusChoice = "all"
$scope.params =
group: $scope.groups[0]
$scope.getStatus()
$scope.$broadcast("dashMapReset")
drawPlots()

initView = () ->
populationData.then((data) ->
Expand Down
6 changes: 6 additions & 0 deletions app/styles/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -299,3 +299,9 @@ div.region-info {
.leaflet-control-layers-expanded {
text-align: left;
}
.min-padding{
padding: 2px !important;
}
.control-label.min-padding{
padding: 10px 2px !important;
}
7 changes: 5 additions & 2 deletions app/views/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,13 @@ <h3 class="panel-title">{{plots[$index].title | translate}}<span class="pull-rig
<div class="col-md-5 col-sm-5 col-xs-5">
<form class="form form-horizontal">
<div class="form-group">
<label for="groupselect" class="col-md-6 col-sm-6 col-xs-6 control-label">{{"Group By"|translate}}:</label>
<div class="col-md-6 col-sm-6 col-xs-6">
<label for="groupselect" class="col-md-3 col-sm-3 col-xs-3 control-label min-padding">{{"Group By"|translate}}:</label>
<div class="col-md-6 col-sm-6 col-xs-6 min-padding">
<select id="groupselect" ng-model="params.group" ng-options="v for v in groups" ng-change="groupBy()" class="form-control"></select>
</div>
<div class="col-md-3 col-sm-3 col-xs-3 min-padding">
<button class="btn btn-warning" ng-click="reset()" translate>Reset</button>
</div>
</div>
</form>
</div>
Expand Down