Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add geometry of selected BigCZ result to map #2213

Merged
merged 1 commit into from
Sep 5, 2017
Merged
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
1 change: 1 addition & 0 deletions src/mmw/js/src/core/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ var MapModel = Backbone.Model.extend({
previousAreaOfInterest: null,
dataCatalogResults: null, // GeoJSON array
dataCatalogActiveResult: null, // GeoJSON
dataCatalogDetailResult: null, // GeoJSON
selectedGeocoderArea: null, // GeoJSON
},

Expand Down
46 changes: 39 additions & 7 deletions src/mmw/js/src/core/views.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ var dataCatalogActiveStyle = {
fillOpacity: 0.2
};

var dataCatalogDetailStyle = {
stroke: true,
color: 'steelblue',
weight: 3,
opacity: 1,
fill: true,
fillColor: 'steelblue',
fillOpacity: 0.5
};

var selectedGeocoderAreaStyle = {
stroke: true,
fill: true,
Expand Down Expand Up @@ -207,6 +217,7 @@ var MapView = Marionette.ItemView.extend({
'change:maskLayerApplied': 'toggleMask',
'change:dataCatalogResults': 'renderDataCatalogResults',
'change:dataCatalogActiveResult': 'renderDataCatalogActiveResult',
'change:dataCatalogDetailResult': 'renderDataCatalogDetailResult',
'change:selectedGeocoderArea': 'renderSelectedGeocoderArea',
},

Expand All @@ -225,6 +236,7 @@ var MapView = Marionette.ItemView.extend({
// L.FeatureGroup instance
_dataCatalogResultsLayer: null,
_dataCatalogActiveLayer: null,
_dataCatalogDetailLayer: null,

// The shape for a selected geocoder boundary result
// L.FeatureGroup instance
Expand Down Expand Up @@ -260,6 +272,7 @@ var MapView = Marionette.ItemView.extend({
this._modificationsLayer = new L.FeatureGroup();
this._dataCatalogResultsLayer = new L.FeatureGroup();
this._dataCatalogActiveLayer = new L.FeatureGroup();
this._dataCatalogDetailLayer = new L.FeatureGroup();
this._selectedGeocoderAreaLayer = new L.FeatureGroup();

this.fitToDefaultBounds();
Expand Down Expand Up @@ -300,6 +313,7 @@ var MapView = Marionette.ItemView.extend({
map.addLayer(this._modificationsLayer);
map.addLayer(this._dataCatalogResultsLayer);
map.addLayer(this._dataCatalogActiveLayer);
map.addLayer(this._dataCatalogDetailLayer);
map.addLayer(this._selectedGeocoderAreaLayer);
},

Expand Down Expand Up @@ -398,6 +412,11 @@ var MapView = Marionette.ItemView.extend({
// Get the maximum zoom level for the initial location
this.updateGoogleMaxZoom({ target: this._leafletMap });
}

if (settings.get('data_catalog_enabled')) {
this._leafletMap.on('zoomend', this.renderDataCatalogDetailResult, this);
this._leafletMap.on('moveend', this.renderDataCatalogDetailResult, this);
}
},

onBeforeDestroy: function() {
Expand Down Expand Up @@ -724,20 +743,33 @@ var MapView = Marionette.ItemView.extend({
},

renderDataCatalogActiveResult: function() {
var geom = this.model.get('dataCatalogActiveResult'),
mapBounds = this._leafletMap.getBounds();
var geom = this.model.get('dataCatalogActiveResult');

this._dataCatalogActiveLayer.clearLayers();
this.$el.removeClass('bigcz-highlight-map');
this._renderDataCatalogResult(geom, this._dataCatalogActiveLayer,
'bigcz-highlight-map', dataCatalogActiveStyle);
},

renderDataCatalogDetailResult: function() {
var geom = this.model.get('dataCatalogDetailResult');

this._renderDataCatalogResult(geom, this._dataCatalogDetailLayer,
'bigcz-detail-map', dataCatalogDetailStyle);
},

_renderDataCatalogResult: function(geom, featureGroup, className, style) {
var mapBounds = this._leafletMap.getBounds();

featureGroup.clearLayers();
this.$el.removeClass(className);

if (geom) {
if ((geom.type === 'MultiPolygon' || geom.type === 'Polygon') &&
drawUtils.shapeBoundingBox(geom).contains(mapBounds)) {
this.$el.addClass('bigcz-highlight-map');
this.$el.addClass(className);
} else {
var layer = this.createDataCatalogShape(geom);
layer.setStyle(dataCatalogActiveStyle);
this._dataCatalogActiveLayer.addLayer(layer);
layer.setStyle(style);
featureGroup.addLayer(layer);
}
}
},
Expand Down
8 changes: 6 additions & 2 deletions src/mmw/js/src/data_catalog/views.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,18 +129,22 @@ var DataCatalogWindow = Marionette.LayoutView.extend({

if (!detailResult) {
this.closeDetails();
App.map.set('dataCatalogActiveResult', null);
App.map.set('dataCatalogDetailResult', null);
} else {
this.detailsRegion.show(new ResultDetailsView({
model: detailResult,
activeCatalog: activeCatalog.id
}));
App.map.set('dataCatalogActiveResult', detailResult.get('geom'));
App.map.set({
'dataCatalogResults': null,
'dataCatalogDetailResult': detailResult.get('geom')
});
}
},

closeDetails: function() {
this.detailsRegion.empty();
this.updateMap();
},

doSearch: function() {
Expand Down
8 changes: 8 additions & 0 deletions src/mmw/sass/base/_map.scss
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@
height: 100%;
position: absolute;
}

&.bigcz-detail-map:after {
content: "";
border: 3px solid steelblue;
width: 100%;
height: 100%;
position: absolute;
}
}

#overlay-subclass-vector .disabled, #overlay-subclass-raster .disabled {
Expand Down