Filtering an array

I have some code finding records with a queryreferenced function but I want to remove any records that have a live field of false so that I can add locations to the Items collection without them showing on the map straightaway. The map is seen at abovedown.co.uk/map

function getLocationsMap() {
 var iCat
 if ($w('#icategory').value.length > 0) {
    iCat = $w('#icategory').value
  } else {
    iCat = "e8dd0d65-dc99-4af1-9506-da1cd9beed38"
  }

 return wixData.queryReferenced("Category", iCat, "Items")
    .then((results) => {
 return results.items; // items is an array of locations from the collection
    })
    .catch((err) => {
 let errorMsg = err;
    });

}

May be I could filter them in the recieving code?

function sendLocations() {
  getLocationsMap()
  .then((locations) => {

 let markers = [];
 for (let i = 0; i < locations.length; i++) {
 let loc = locations[i];
      markers.push({title: loc.title, position: {lat: loc.lat, lng: loc.long}});
    }
    $w('#htmlMap').postMessage({markers});
  });
}

Also I don’t understand why I need a return on the wixdata line and the results.items but if I remove either it no longer shows the locations on the map. Your help is much appreciated.

Simple solution was to test the live field in the for loop.

for (let i = 0; i < locations.length; i++) {
 let loc = locations[i];
      if (loc.live) {
      markers.push({title: loc.title, position: {lat: loc.lat, lng: loc.long}});
      }
    }

hello sir could you share the code for https://www.abovedown.co.uk/map

i would like to design something like this,i can only show locations but non…clickable