Calculator Tools Calculator Tools
Create

Beer Finder

Jan 7, 2024

About this app

Find the best beer prices and bars near you

Beer Finder Beer Finder

Related apps

Put this on your site

Source

                    <html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1">

<title>Beer Finder</title>
<meta name="description" content="Find the best beer prices and bars near you">
<meta name="keywords" content="beer, pricing, bars, reviews, geo-tagged">

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">

<script type="text/javascript">
try {
document.addEventListener("DOMContentLoaded", function() {
// Get user's current location using Geolocation API
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
console.log("Geolocation is not supported by this browser.");
}

function showPosition(position) {
const latitude = position.coords.latitude;
const longitude = position.coords.longitude;

// Display user's location on a map using Google Maps API
const mapUrl = `https://maps.googleapis.com/maps/api/staticmap?center=${latitude},${longitude}&zoom=15&size=600x300&maptype=roadmap&markers=color:red%7C${latitude},${longitude}&key=YOUR_API_KEY`;
const mapImage = `<img src="${mapUrl}" alt="Map" class="img-fluid">`;
$("#map-container").html(mapImage);

// Fetch beer pricing data from user-supplied real-time sources
// and display it on the app
fetchBeerPricing(latitude, longitude);
}

function fetchBeerPricing(latitude, longitude) {
// Make API request to get beer pricing data
const beerPricingUrl = `https://api.example.com/beer/pricing?lat=${latitude}&lng=${longitude}`;
fetch(beerPricingUrl)
.then(response => response.json())
.then(data => {
// Process and display pricing data
const beerList = data.beers;
const pricingTable = `
<table class="table">
<thead>
<tr>
<th>Beer</th>
<th>Price</th>
</tr>
</thead>
<tbody>
${beerList.map(beer => `
<tr>
<td>${beer.name}</td>
<td>$${beer.price}</td>
</tr>
`).join("")}
</tbody>
</table>
`;
$("#pricing-container").html(pricingTable);
})
.catch(error => {
console.log("Error fetching beer pricing data:", error);
});
}
});

} catch (error) {
throw error;
}
</script>

<style>
body {
background-color: #f2f2f2;
font-family: 'Roboto', sans-serif;
}

h1 {
color: #333;
text-align: center;
margin-top: 20px;
}

#map-container {
margin-top: 20px;
text-align: center;
}

#pricing-container {
margin-top: 20px;
}

table {
width: 100%;
border-collapse: collapse;
margin-top: 10px;
}

th, td {
padding: 8px;
text-align: left;
border-bottom: 1px solid #ddd;
}

th {
background-color: #333;
color: #fff;
}
</style>
</head>
<body>
<div id="main-container" class="container">
<h1>Beer Finder</h1>

<div id="map-container"></div>

<div id="pricing-container"></div>
</div>
</body>
</html>