Google maps API - Async content for InfoWindow in google maps

20 Views Asked by At

I am using google maps. I have to load on the map different markers, and for every mark link different contents for singole InfoWindow. Content for InfoWindow have to be loaded asyncronous by an ajax function that read data from a database. But, when I call Open to InfoWindow, the content remain empty beacuse the content function is asyncronous.

How can I solve? I cannot load all the contents at the maps loading, beacuse it will be too slow. Any suggestions? I would like to retrive InfoWindow content only whan I click on the single marker

I tried this, but it did not work

marker.addListener("click", () => {

            (async () => {
            var content = await GM2024CIW(location[0], lin, devUrl, location[4]);
                infowindow.setContent(content.response);
                infowindow.open({ anchor: marker, map });
            
            })();
        });
0

There are 0 best solutions below