Warn when map container's width or height are zero
This commit is contained in:
+17
-10
@@ -1500,18 +1500,25 @@ class PluggableMap extends BaseObject {
|
|||||||
this.setSize(undefined);
|
this.setSize(undefined);
|
||||||
} else {
|
} else {
|
||||||
const computedStyle = getComputedStyle(targetElement);
|
const computedStyle = getComputedStyle(targetElement);
|
||||||
this.setSize([
|
const width =
|
||||||
targetElement.offsetWidth -
|
targetElement.offsetWidth -
|
||||||
parseFloat(computedStyle['borderLeftWidth']) -
|
parseFloat(computedStyle['borderLeftWidth']) -
|
||||||
parseFloat(computedStyle['paddingLeft']) -
|
parseFloat(computedStyle['paddingLeft']) -
|
||||||
parseFloat(computedStyle['paddingRight']) -
|
parseFloat(computedStyle['paddingRight']) -
|
||||||
parseFloat(computedStyle['borderRightWidth']),
|
parseFloat(computedStyle['borderRightWidth']);
|
||||||
|
const height =
|
||||||
targetElement.offsetHeight -
|
targetElement.offsetHeight -
|
||||||
parseFloat(computedStyle['borderTopWidth']) -
|
parseFloat(computedStyle['borderTopWidth']) -
|
||||||
parseFloat(computedStyle['paddingTop']) -
|
parseFloat(computedStyle['paddingTop']) -
|
||||||
parseFloat(computedStyle['paddingBottom']) -
|
parseFloat(computedStyle['paddingBottom']) -
|
||||||
parseFloat(computedStyle['borderBottomWidth']),
|
parseFloat(computedStyle['borderBottomWidth']);
|
||||||
]);
|
if (height === 0 || width === 0) {
|
||||||
|
// eslint-disable-next-line
|
||||||
|
console.warn(
|
||||||
|
"No map visible because the map container's width or height are 0."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
this.setSize([width, height]);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.updateViewportSize_();
|
this.updateViewportSize_();
|
||||||
|
|||||||
Reference in New Issue
Block a user