From 5d04ff57f9ca4a190faa87bf9767ffe0aefff358 Mon Sep 17 00:00:00 2001 From: Casey Cesari Date: Thu, 31 Aug 2017 16:14:01 -0400 Subject: [PATCH] fixup! Add geometry of selected BigCZ result to map --- src/mmw/js/src/core/views.js | 38 +++++++++++++++--------------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/src/mmw/js/src/core/views.js b/src/mmw/js/src/core/views.js index 9a3c503a2..ba39d253f 100644 --- a/src/mmw/js/src/core/views.js +++ b/src/mmw/js/src/core/views.js @@ -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); } } },