Skip to content

Commit

Permalink
Fix bad computation of aspect ratio
Browse files Browse the repository at this point in the history
In some cases, the frustum aspect ratio was set to NaN, which
was breaking Cesium.
  • Loading branch information
gberaudo committed Apr 11, 2016
1 parent 3eb63e1 commit e5e1d96
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/ol3cesium.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,11 @@ olcs.OLCesium.prototype.handleResize_ = function() {
var width = this.canvas_.clientWidth;
var height = this.canvas_.clientHeight;

if (width === 0 | height === 0) {
// The canvas DOM element is not ready yet.
return;
}

if (width === this.canvasClientWidth_ &&
height === this.canvasClientHeight_ &&
!this.resolutionScaleChanged_) {
Expand Down Expand Up @@ -446,10 +451,10 @@ olcs.OLCesium.prototype.setResolutionScale = function(value) {
*/
olcs.OLCesium.prototype.throwOnUnitializedMap_ = function() {
var map = this.map_;
var center = map.getView().getCenter();
var resolution = map.getView().getResolution();
if (!center || isNaN(center[0]) || isNaN(center[1]) || !resolution) {
var view = map.getView();
var center = view.getCenter();
if (!view.isDef() || isNaN(center[0]) || isNaN(center[1])) {
throw new Error('The OL3 map is not properly initialized: ' +
center + ' / ' + resolution);
center + ' / ' + view.getResolution());
}
};

0 comments on commit e5e1d96

Please sign in to comment.