Google Map element works fine, except in a Lightbox

I have used the Wix google maps element in Editor and a few lines of code to display a single location by lat/long coordinates (overriding the address set in the Editor), and never had any problems. But when I try to use the same element and code in a lightbox it inexplicably works once (if at all), then never again.

To troubleshoot, and to rule out coding errors, I tried replacing my code [which passed variables to the lightbox using getContext() ] with Wix’s sample code and a fixed location. The results were the same: the lightbox map correctly displays the location the first time I add the maps element (“#googleMaps1”) to the lightbox and run the code, but the next time and beyond (without any changes to code!) it only shows the element’s default Wix HQ location. It also seems to make no difference whether I use a button link or code to open the lightbox.

Anyone have an idea what is going on?

Map lightbox code:

$w.onReady(function () {
$w(“#googleMaps1”).location = {
“latitude”: 49.2745117,
“longitude”: -123.104314,
“description”:“Somewhere over Vancouver”
};
});

I’d imagine a lot of sites use lightboxes to display their location maps. Any guesses what may be keeping it from working for me? Code works fine on all static and dynamic pages, but not inside a lightbox.

I would say everything is correct and working like expected.

Your lightbox loads the CONTEXT-DATA one-time-only → exacly when opening the lighbox.
To be able to trigger an UPDATE of LIGHBOX-DATA again —> you need to REOPEN the LIGHTBOX again. Once you have reopened the lighbox, you are able to send new data to lighbox → but this means you will have to reopen the lightbox again and again and again.

Your concept is wrong. Instead you should refresh your map-data directly inside of the opened LIGHBOX using a dataset inside the lighbox or doing it by code, using a query.

Or you continue to follow your chosed direction, but in your case you will have always to reopen the LIGHBOX, to be able to RE-UPDATE the DATA for LIGHBOX, which you are sending from your page.