Map location is not being updated

Hello,

I am using a map on a dynamic page to show the location of places (parks in my case).

I use the following code:


$w.onReady( function () {
// Set park location in the map
$w(“#parks”).onReady( () => {
let itemObj = $w(“#parks”).getCurrentItem();
$w(“#map”).location = {
“latitude”: itemObj.latitude,
“longitude”: itemObj.longitude,
“description”: itemObj.title,
};
console.log(itemObj.latitude, " , ", itemObj.longitude);
});
});


On debug, the map is showing the correct location, however, on the published website, the default location is shown.

It feels like the onReady function is late to render the map before the page is loaded, however, I am not sure how to fix it. Will appreciate your help.

I can see that there is an upcoming feature to address this:
“Google Maps Component - Connect this component to an Address field in your collection to show a Google map on a regular or dynamic page”

But still interested in solving this sooner than later :slight_smile: