Skip to content

Commit

Permalink
review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasneirynck committed Jul 24, 2017
1 parent 24e54bd commit ab29e41
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions src/core_plugins/region_map/public/choropleth_layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,7 @@ function makeChoroplethStyler(data, colorramp, joinField) {
const { min, max } = getMinMax(data);
const outstandingFeatures = data.slice();


const joinedShapes = [];
const boundsOfAllFeatures = new L.LatLngBounds();
return {
getLeafletStyleFunction: function (geojsonFeature) {
let lastIndex = -1;
Expand All @@ -226,7 +225,10 @@ function makeChoroplethStyler(data, colorramp, joinField) {
}

outstandingFeatures.splice(lastIndex, 1);
joinedShapes.push(geojsonFeature);

const boundsOfFeature = L.geoJson(geojsonFeature).getBounds();
boundsOfAllFeatures.extend(boundsOfFeature);

return {
fillColor: getChoroplethColor(match.value, min, max, colorramp),
weight: 2,
Expand All @@ -243,19 +245,7 @@ function makeChoroplethStyler(data, colorramp, joinField) {
return outstandingFeatures.map((bucket) => bucket.term);
},
getLeafletBounds: function () {

if (!joinedShapes.length) {
return null;
}

const bounds = L.geoJson(joinedShapes[0]).getBounds();
for (let i = 1; i < joinedShapes.length; i++) {
const otherBounds = L.geoJson(joinedShapes[i]).getBounds();
bounds.extend(otherBounds);
}
return bounds;


return boundsOfAllFeatures.isValid() ? boundsOfAllFeatures : null;
}
};

Expand Down

0 comments on commit ab29e41

Please sign in to comment.