import wixData from 'wix-data'; // Function to calculate distance between two lat-lng points (Haversine formula) function calculateDistance(lat1, lon1, lat2, lon2) { const R = 6371; // Radius of Earth in km const dLat = (lat2 - lat1) * Math.PI / 180; const dLon = (lon2 - lon1) * Math.PI / 180; const a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.cos(lat1 * Math.PI / 180) * Math.cos(lat2 * Math.PI / 180) * Math.sin(dLon / 2) * Math.sin(dLon / 2); const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); const distance = R * c; // Distance in km return distance; } // Function to find the nearest store from the user's location async function findClosestStore(userLat, userLng) { // Query all stores from the Wix database let result = await wixData.query("StoreLocations") .find(); let closestStore = null; let minDistance = Infinity; // Loop through stores and calculate the distance to each one result.items.forEach(store => { const storeLat = store.latitude; const storeLng = store.longitude; const distance = calculateDistance(userLat, userLng, storeLat, storeLng); // Update the closest store if this one is closer if (distance < minDistance) { minDistance = distance; closestStore = store; } }); return closestStore; } // Example of using the function after getting user's location: $w.onReady(function () { // For example, you could get the user's location using the browser geolocation API: if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(async function(position) { const userLat = position.coords.latitude; const userLng = position.coords.longitude; const closestStore = await findClosestStore(userLat, userLng); if (closestStore) { // Display the closest store on the page (you can use text elements, repeaters, etc.) $w("#storeName").text = closestStore.name; $w("#storeAddress").text = closestStore.address; $w("#storeDistance").text = `Distance: ${minDistance.toFixed(2)} km`; } }); } });
top of page
IMG_0421_edited.jpg
B (23).png

Claim Your FREE trial

Find the nearest location
servises

What we offer 

IMG_2599_edited_edited.jpg

One to one

unnamed (1)_edited.jpg

FA Qualified/DBS checked coach
Fun sessions
Develop as a player
Improve your skill

What can you expect on a typical day at the session?

  • Fun drills

  • Challenges to improve skills

  • Small sided games

  • 1hr sessions

  • Equipment  such as balls, cones and goalposts are provided

Join the fun

About
B (22).PNG

About the club
 

Galaxy stars is based in the UK

We deliver fun football and development sessions to young players, aged between 5 and 16 for both boys and girls.

We make football fun for players of any ability.

bottom of page