Google Maps callback not executing

I have a google maps API but the map isn’t loading, if I enter the page with the navigation.
I have to refresh the page once, before the map is loading.

I think the callback doesn’t get executed, when entering the page with the navigation.

I added a postMessage function, when I enter the page with the navigation I get no message. When I refresh the page once I get the message “yes”.

Is this actually a map error, or is this error caused by Wix?

  <title>Simple Map</title>
  <style type="text/css">
    #map {
      height: 100%;

    body {
      height: 100%;
      margin: 0;
      padding: 0;
  <script src=""></script>

  <div id="map"></div>
    function initMap() {

        "type": "yes"
      }, "*");

      const myLatLng = {
        lat: -25.363,
        lng: 131.044
      const map = new google.maps.Map(document.getElementById("map"), {
        zoom: 4,
        center: myLatLng,

  <script src="" async></script>
1 Like

Hi, I’m Talia from the EditorX product team.
Would you mind sharing your site’s URL? This will help us further investigate this issue. We look forward to hearing from you. Thanks for your help!

Finallly I found a fix for this problem.
For some reason Wix doesn’t load the html when you switch the site over the navigation menue, so the callback from the map doesn’t get executed (just when you refresh)

How to fix this:

import wixData from 'wix-data';

$w.onReady(function () {


 let markers = [];

 return wixData.query("GoogleMaps")
 .then((results) => {
 markers = results.items[0].googleMapArray;

//You have to send a message to the HTML, else it won't load
 $w("#htmlMap").postMessage({ markers });
 // ad the part above

 $w("#htmlMap").onMessage((event) => {

 if ( === 'ready') {
 return $w('#htmlMap').postMessage({ markers });

Just send a message to the html, then it will execute the callback, and when the html is loaded ( === ‘ready’) you can send the data.