Merge pull request #10935 from ejn/fix-panIntoView-no-options

Fix calling Overlay.panIntoView with no options
This commit is contained in:
Andreas Hocevar
2020-04-17 11:13:22 +02:00
committed by GitHub

View File

@@ -408,10 +408,10 @@ class Overlay extends BaseObject {
/**
* Pan the map so that the overlay is entirely visible in the current viewport
* (if necessary).
* @param {PanIntoViewOptions|undefined} panIntoViewOptions Options for the pan action
* @param {PanIntoViewOptions=} opt_panIntoViewOptions Options for the pan action
* @api
*/
panIntoView(panIntoViewOptions) {
panIntoView(opt_panIntoViewOptions) {
const map = this.getMap();
if (!map || !map.getTargetElement() || !this.get(Property.POSITION)) {
@@ -425,6 +425,8 @@ class Overlay extends BaseObject {
outerHeight(element),
]);
const panIntoViewOptions = opt_panIntoViewOptions || {};
const myMargin =
panIntoViewOptions.margin === undefined ? 20 : panIntoViewOptions.margin;
if (!containsExtent(mapRect, overlayRect)) {