Google Map Query Limitation

Hi Wix Wizards and Velo experts!

We are working with a non-profit organization to move their website from Wordpress to Wix. One of the major components of their site is an interactive Google Map that shows pins for every person who has pledged to have a pollinator safe property. We have 2,375 people who have pledged, but we are running into a query limit on the Google Map API Wix element and it is only showing a portion of the pins (it looks like maybe around 200-300 pins vs the full 2,375 pins in the database). So our Velo code is working (thanks Nayeli!!), but it seems we are running into a Wix map query limitation.

I am really hoping that there maybe workaround to this Wix Query Limitation for the Google Map API for the Wix map element? See the above screenshot where it shows our Wordpress version that has at least a 1000 more pins than the working version on our Wix website is showing.

I did talk with Wix support and they said it is limited to around 500-1000 queries for page loading reasons, but this works fine and loads fast in Wordpress so I’m really hoping we can figure out a work-around or Wix can offer a query limit increase so that we can show all the pledges on the map.

Here is the map on Wix that is only showing a small portion of the 2,375 items in our database:
pollinators1.wixsite. com/site/map

Here is their old Wordpress site that has the map with ALL the 2375 pins showing:
peopleandpollinators. org/map/

I hope one of you geniuses can help us make this work! I don’t want to have to keep them on Wordpress, especially since we’ve designed such a beautiful new website for them on Wix!

Ive attached a screenshot below that shows our Wix Content Manager Database that has the 2,375 items with the latitude and longitude to feed to the Google Map API. Some of them are working, just not all.

Thanks!

Not sure, but perhaps you can generate your own “Google-Map” trough an → HTML-Component (using your own google-maps-ID-Token). Perhaps then you won’t have all the limitations.

Just an idea (not proved)!

@idelle The main issue is that Wix limits data query to 1000 per request, so you’ll need to do multiple round of query in order to retrieve all items.

I don’t think it’s possible to modify that behaviour but, as @russian-dima suggested, you can create your own google map on Wix via Html element, or better, via custom web component.

I’ve built several maps that way and I believe there is no real limitation on the number of data points you can display on a map but the more point you had the slower the map become:

Check out my prototype https://quentinces.wixsite.com/wix-geo-query you’ll see that when the range is greater than 10000km, it become a bit laggy (there are about 6000 data points but I believe it displays only 1000 max)

That’s why it’s recommended to only load points that are in the viewport and

Kentin → you little GENIUS ! I like your stuff!

I suggest using Marker Clustering display option of Google Maps, which results in a cleaner display of the map. See the Example: Multiple Markers Google Maps to see how this is done.

We have the full database of 2400 map pin points uploaded now to the Wix database, and it is showing way more pins now, but it is still limited to 1000 data points as the Dataset Settings “Numbers of items to display” defaults back to 1000 even if we type in 2400.

SUPER SLOW LOADING
Despite it potentially showing only 1000 pins, the map is now loading verrrry slowly (a bit of slowness was anticipated, but it’s so extremely slow that I don’t think it’s usable, it takes 10-20+ seconds to “load” the markers on my super-fast fiber internet connection, so it’s not good, it loads the map pretty quick, but it’s empty for a long time before loading the pins, if at all), check it out - does it load as slowly for you?
https://pollinators1.wixsite.com/site/map

In contrast, here is their instantly loading original Wordpress embedded map that also references all the data pin points (using a different custom coded process combining an Amazon Web Services Lambda Function and Cloudwatch and a WP plugin to generate the Google Map with all the ~2400 pins), this one loads instantly and has all the points: https://pollinators1.wixsite.com/site/embedded-map

We may just embed this WP page version when we launch since the Wix version is so slow loading unless we can find a solution, not ideal, but the slowness of the new Wix map is not user-friendly.

Any suggestions on what could be done to improve the load time on the Wix map? How would we set this up to allow for multiple round of querys so it can load pins maybe 500 at a time until it is fully loaded?

Here is our custom Wix Velo code for the Google Map: (thanks Nayeli!):

Google Maps APIs
<style> 
  html, 
  body { 
    height: 100%; 
    margin: 0; 
    padding: 0; 
  } 
  #map { 
    height: 100%; 
  } 
</style> 

<script> 
  /* 
  { 
    isLocation : true, 
    locations: [ 
      { 
        lat: 1234123, 
        long: 1324112, 
        info: "state name display in map", 
        id: "repeater ID" 
      } 
    ] 
  } 
  */ 
  var markersArray = []; 
  var lastLocation = []; 
  let ready = false; 

  window.onmessage = event => { 
    console.log("Message received!", event.data); 
    if (event.data) { 
      if (event.data === "clear") { 
        setMapOnAll(null); 
      } else { 
        let data = event.data; 
        if (data.isLocation) { 
          ready = true; 
          let location = JSON.parse(data.locations); 
          window.parent.postMessage("Test", "*"); 
          initMap(location); 
        } 
      } 
    } 
  }; 

  function initMap(receivedData) { 
    if (!ready) { 
      window.parent.postMessage("Ready", "*"); 
    } 

    console.log("Map initiated", receivedData); 
    var locations = receivedData; 

    var map = new google.maps.Map(document.getElementById("map"), { 
      zoom: 7, 
      center: new google.maps.LatLng(39.146965, -105.530272), 
      mapTypeId: google.maps.MapTypeId.ROADMAP, 
      maxZoom:15 
    }); 

    setCenter(map, locations); 
    var infowindow = new google.maps.InfoWindow({});   

    // var marker, i; 

    // Upper Bound 

    var markerIcon = { 
      url: "https://static.wixstatic.com/media/139de8_5f9d94c49b76412cb1f4d52e5806c3a0~mv2.png", 
      scaledSize: new google.maps.Size(40, 40), 
      origin: new google.maps.Point(0, 0), 
      anchor: new google.maps.Point(32, 28) 
    }; 

    var markerLabel = " "; 

    // Lower Bound 

    for (i = 0; i < locations.length; i++) { 
      marker = new google.maps.Marker({ 
        map: map, 
        animation: google.maps.Animation.DROP, 
        icon: markerIcon, 
        position: new google.maps.LatLng( 
          String(locations[i].lat), 
          String(locations[i].long) 
        ), 
        label: { 
          text: markerLabel, 
          fontSize: "16px", 
          fontWeight: "bold" 
        }, 
        labelAnchor: new google.maps.Point(18, 12), 
        labelClass: "my-custom-class-for-label" 
      }); 
      markersArray.push(marker); 
      google.maps.event.addListener( 
        marker, 
        "click", 
        (function(marker, i) { 
          return function() { 
            infowindow.setContent(locations[i].info); 
            infowindow.open(map, marker); 
            window.parent.postMessage({ 

“click”:true,
id: locations[i].id
}, “*”);
};
})(marker, i)
);
}
}

  function setMapOnAll(map) { 
    for (var i = 0; i < markersArray.length; i++) { 
      markersArray[i].setMap(map); 
    } 
  } 
  function setCenter(map, locations) { 
    //Example values of min & max latlng values 
    let lats = locations.map(_ => _.lat); 
    let longs = locations.map(_ => _.long); 
    let lat_min = Math.max(...lats); 
    let lat_max = Math.min(...lats); 
    let lng_min = Math.max(...longs); 
    let lng_max = Math.min(...longs); 

    map.setCenter( 
      new google.maps.LatLng( 
        (lat_min), 
        (lng_min) 
      ) 
    ); 
    map.fitBounds( 
      new google.maps.LatLngBounds( 
        //bottom left 
        new google.maps.LatLng(37.332358, -108.804395), 
        //top right 
        new google.maps.LatLng(40.586131, -102.831245) 
      ) 
    ); 
  } 
</script> 
<!-- <script src="script.js"></script> --> 
<script 
  async 
  defer 
  src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAaXLjETVbs_fwIU2Xu6l5XQPLHbHPfkno&callback=initMap" 
></script> 

Thanks for any ideas on how to improve this!