Skip to content

Commit

Permalink
workaround for ckan#70 where (ol) WMTS layers freeze the browser
Browse files Browse the repository at this point in the history
  • Loading branch information
olivierdalang committed Feb 24, 2020
1 parent 82ce623 commit 4d03b97
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions ckanext/geoview/public/js/vendor/ol-helpers/ol-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,11 @@ ol.proj.addProjection(createEPSG4326Proj('EPSG:4326:LONLAT', 'enu'));


ol.Map.prototype.addLayerWithExtent = function (layer) {
layer.setVisible(false);
this.addLayer(layer)

// fit to layer extent only if layer visible
if (layer.getVisible() && layer.getSource()) {
if (layer.getSource()) {

var _view = this.getView();
var zoomToExtent = function() {
Expand All @@ -122,8 +123,10 @@ ol.proj.addProjection(createEPSG4326Proj('EPSG:4326:LONLAT', 'enu'));
isNumeric(projectedBbox[1]) &&
isNumeric(projectedBbox[2]) &&
isNumeric(projectedBbox[3]))

_view.fit(projectedBbox, {constrainResolution: false})
{
_view.fit(projectedBbox, {constrainResolution: false});
layer.setVisible(true);
}
else {
console.warn("Adding layer : could not find extent to zoom to")
}
Expand Down

0 comments on commit 4d03b97

Please sign in to comment.