Creating an interactive web experience for a map of South African wineries is a fantastic idea! Below is a conceptual outline and code snippet to help you get started. This example uses HTML, CSS, and JavaScript with the Leaflet.js library for the map and some basic interactivity. You can expand this further by integrating a backend or database for dynamic data.
Conceptual Features
Map Display : A map of South Africa with markers for wineries.
Winery Information : Each marker shows details about the winery, including tasting and pairing costs, times, and other details.
Route Planner : Users can select wineries to create a route, and the app calculates the total time (including default tasting time at each winery).
Fun Colors and Themes : Use vibrant colors and playful icons to make the experience engaging.
Code Example
HTML
html Copy code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>South Africa Winery Map</title>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css" />
<link rel="stylesheet" href="styles.css">
</head>
<body>
<header>
<h1>🍷 South Africa Winery Explorer</h1>
<p>Select wineries to create your tasting route!</p>
</header>
<div id="map"></div>
<div id="route-planner">
<h2>Your Route</h2>
<ul id="selected-wineries"></ul>
<p>Total Time: <span id="total-time">0</span> hours</p>
<button id="clear-route">Clear Route</button>
</div>
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
<script src="script.js"></script>
</body>
</html>
CSS (styles.css)
css Copy code
body {
font-family: 'Arial', sans-serif;
margin: 0;
padding: 0;
background-color: #fdf5e6;
color: #333;
}
header {
text-align: center;
background-color: #ffcc99;
padding: 1rem;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}
header h1 {
font-size: 2rem;
color: #8b0000;
}
#map {
height: 70vh;
width: 100%;
}
#route-planner {
padding: 1rem;
background-color: #fff8dc;
border-top: 2px solid #8b0000;
}
#route-planner h2 {
color: #8b0000;
}
#selected-wineries {
list-style: none;
padding: 0;
}
#selected-wineries li {
margin: 0.5rem 0;
}
button {
background-color: #8b0000;
color: white;
border: none;
padding: 0.5rem 1rem;
cursor: pointer;
border-radius: 5px;
}
button:hover {
background-color: #a52a2a;
}
JavaScript (script.js)
javascript Copy code
// Initialize the map
const map = L.map('map').setView([-33.9249, 18.4241], 8); // Centered on Cape Town
// Add OpenStreetMap tiles
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© OpenStreetMap contributors'
}).addTo(map);
// Sample winery data
const wineries = [
{
name: "Stellenbosch Winery",
coords: [-33.9321, 18.8602],
tastingCost: 150,
pairingCost: 250,
tastingTime: 1 // in hours
},
{
name: "Franschhoek Winery",
coords: [-33.9099, 19.1256],
tastingCost: 200,
pairingCost: 300,
tastingTime: 1.5
},
{
name: "Paarl Winery",
coords: [-33.7342, 18.9621],
tastingCost: 180,
pairingCost: 280,
tastingTime: 1.2
}
];
// Default tasting time
const defaultTastingTime = 1; // in hours
// Selected wineries
let selectedWineries = [];
// Add winery markers to the map
wineries.forEach((winery, index) => {
const marker = L.marker(winery.coords).addTo(map);
marker.bindPopup(`
<strong>${winery.name}</strong><br>
Tasting Cost: R${winery.tastingCost}<br>
Pairing Cost: R${winery.pairingCost}<br>
Tasting Time: ${winery.tastingTime} hours<br>
<button onclick="addToRoute(${index})">Add to Route</button>
`);
});
// Add winery to route
function addToRoute(index) {
const winery = wineries[index];
if (!selectedWineries.includes(winery)) {
selectedWineries.push(winery);
updateRoute();
}
}
// Update route display
function updateRoute() {
const routeList = document.getElementById('selected-wineries');
const totalTimeEl = document.getElementById('total-time');
routeList.innerHTML = '';
let totalTime = 0;
selectedWineries.forEach(winery => {
const li = document.createElement('li');
li.textContent = winery.name;
routeList.appendChild(li);
totalTime += winery.tastingTime || defaultTastingTime;
});
totalTimeEl.textContent = totalTime.toFixed(1);
}
// Clear route
document.getElementById('clear-route').addEventListener('click', () => {
selectedWineries = [];
updateRoute();
});
How It Works
Map Initialization : The map is centered on Cape Town, South Africa, using Leaflet.js.
Winery Markers : Each winery is represented by a marker with a popup showing details and an "Add to Route" button.
Route Planner : When a winery is added to the route, it appears in the route planner, and the total time is updated.
Clear Route : Users can clear their route and start over.
Next Steps
Dynamic Data : Replace the static wineries array with data from a database or API.
Routing : Use a routing library (e.g., Leaflet Routing Machine) to calculate driving routes between wineries.
Styling : Add custom icons for wineries and improve the overall design.
Mobile Optimization : Ensure the app is fully responsive for mobile users.
This is a great starting point for your interactive winery map! Let me know if you need help with any specific part. 🍇