Skip to content

Commit

Permalink
fixup! Add geometry of selected BigCZ result to map
Browse files Browse the repository at this point in the history
  • Loading branch information
caseycesari committed Aug 31, 2017
1 parent 210c581 commit 5d04ff5
Showing 1 changed file with 16 additions and 22 deletions.
38 changes: 16 additions & 22 deletions src/mmw/js/src/core/views.js
Original file line number Diff line number Diff line change
Expand Up @@ -743,39 +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');

if (geom) {
if ((geom.type === 'MultiPolygon' || geom.type === 'Polygon') &&
drawUtils.shapeBoundingBox(geom).contains(mapBounds)) {
this.$el.addClass('bigcz-highlight-map');
} else {
var layer = this.createDataCatalogShape(geom);
layer.setStyle(dataCatalogActiveStyle);
this._dataCatalogActiveLayer.addLayer(layer);
}
}
this._renderDataCatalogResult(geom, this._dataCatalogActiveLayer,
'bigcz-highlight-map', dataCatalogActiveStyle);
},

renderDataCatalogDetailResult: function() {
var geom = this.model.get('dataCatalogDetailResult'),
mapBounds = this._leafletMap.getBounds();
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();

this._dataCatalogDetailLayer.clearLayers();
this.$el.removeClass('bigcz-detail-map');
featureGroup.clearLayers();
this.$el.removeClass(className);

if (geom) {
if ((geom.type === 'MultiPolygon' || geom.type === 'Polygon') &&
drawUtils.shapeBoundingBox(geom).contains(mapBounds)) {
this.$el.addClass('bigcz-detail-map');
this.$el.addClass(className);
} else {
var layer = this.createDataCatalogShape(geom);
layer.setStyle(dataCatalogDetailStyle);
this._dataCatalogDetailLayer.addLayer(layer);
layer.setStyle(style);
featureGroup.addLayer(layer);
}
}
},
Expand Down

0 comments on commit 5d04ff5

Please sign in to comment.