Stores Near You

Shows nearby retail stores in a horizontal carousel, sorted by distance when location is allowed, with store image, address, hours, and tap-to-open directions.

async function locateStore() {
    try {
        let permission = Superfans.variables.device?.permissions?.location;
        if (permission !== "granted") {
            const response = await Superfans.actions.requestLocationPermission();
            if (response?.status === "failed") {
                return;
            }
        }
        const response = await Superfans.actions.getDeviceLocation();
        const { latitude, longitude } = normalizeLocationResponse(response);
        if (latitude == null || longitude == null) {
            return;
        }
        const sorted = stores
            .map(s => ({
                ...s,
                distanceMiles: haversineDistance(latitude, longitude, s.lat, s.lng)
            }))
            .sort((a, b) => a.distanceMiles - b.distanceMiles);
        preloadAndRender(sorted);
    } catch (err) {
        console.warn('locateStore error:', err);
    }
}

function openStore(url) {
    Superfans.actions.openUrl({ path: url });
}

Did this page help you?