Wix Query Question

Hello-

I am making a facilities database with dynamic pages. There are multiple clinics at each location. So I made two databases. The first for locations, which includes address and lat/longs. The second for clinics. The two databases are referenced based on location.

For each clinic dynamic page, I’d like to add a google map. My strategy was to query the Location database based on the a text component on the dynamic page that contains the location referenced from the Clinic database.

import wixData from ‘wix-data’;
let selectedLongitude = “”;
let selectedLatitude = “”;
let selectedLocation = “”

$w.onReady(()=> {
$w(“#LocationDataset”).onReady(() => {
const Location = $w(“#Location”);
wixData.query(“LocationData”)
.eq(“Location”, Location)
.find()
.then( (results)=> {
let firstItem = results.items[0];//First item in results
selectedLatitude = firstItem.latitude;
selectedLongitude = firstItem.longitude;
selectedLocation = firstItem.location;
$w(“#googleMaps1”).location = {
“latitude”: selectedLatitude,
“longitude”: selectedLongitude,
“description”: selectedLocation
};
});
});
})

I dont get any errors with this code, but it doesnt work either. The $w(“#Location”) is the text box of the location on the dynamic page. The $w(“#googleMaps1”) is the google map component on the page. I have both datasets loaded on the page.

Any thoughts?

const Location should equal $w(‘#Location’).text;

@David that didnt fix the problem but maybe was a part of it?

I think I figured part of it out, the database reference for location needed a lowercase L.