Skip to content

Commit afcd78b

Browse files
prushforprushfor
authored andcommitted
Revert / convert extentload / foo event to layer.whenReady when processing
non-inplace links.
1 parent 446e259 commit afcd78b

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

src/mapml/utils/Util.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -526,12 +526,21 @@ export var Util = {
526526
newLayer = true;
527527
}
528528
if (!link.inPlace && newLayer)
529-
if (zoomTo)
530-
layer.parentElement.zoomTo(+zoomTo.lat, +zoomTo.lng, +zoomTo.z);
531-
else layer.zoomTo();
532-
533-
if (opacity) layer.opacity = opacity;
534-
map.getContainer().focus();
529+
layer.whenReady().then(() => {
530+
if (
531+
newLayer &&
532+
['_parent', '_self'].includes(link.target) &&
533+
layer.parentElement.querySelectorAll('layer-').length === 1
534+
)
535+
layer.parentElement.projection = layer._layer.getProjection();
536+
if (layer.extent) {
537+
if (zoomTo)
538+
layer.parentElement.zoomTo(+zoomTo.lat, +zoomTo.lng, +zoomTo.z);
539+
else layer.zoomTo();
540+
}
541+
if (opacity) layer.opacity = opacity;
542+
map.getContainer().focus();
543+
});
535544
} else if (zoomTo && !link.inPlace && justPan) {
536545
leafletLayer._map.options.mapEl.zoomTo(
537546
+zoomTo.lat,

0 commit comments

Comments
 (0)