View / handle resolutions array with length=1

This commit is contained in:
Olivier Guyot
2019-01-20 16:32:15 +01:00
parent 49662b019c
commit b5273babb5

View File

@@ -971,6 +971,9 @@ class View extends BaseObject {
*/
getResolutionForZoom(zoom) {
if (this.resolutions_) {
if (this.resolutions_.length <= 1) {
return 0;
}
const baseLevel = clamp(Math.floor(zoom), 0, this.resolutions_.length - 2);
const zoomFactor = this.resolutions_[baseLevel] / this.resolutions_[baseLevel + 1];
return this.resolutions_[baseLevel] / Math.pow(zoomFactor, clamp(zoom - baseLevel, 0, 1));