JSFiddle - React, Tailwind, and code Playground
by fxi
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Geneva Map App</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/maplibre-gl/4.0.0/maplibre-gl.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/maplibre-gl/4.0.0/maplibre-gl.min.css" rel="stylesheet">
<script src="https://cdn.tailwindcss.com"></script>
<style>
body, html {
margin: 0;
padding: 0;
height: 100%;
}
#map {
width: 100%;
height: 100%;
transition: height 0.3s ease;
}
#info {
display: none;
height: 33.333%;
background-color: white;
padding: 1rem;
overflow-y: auto;
}
.marker {
background-color: red;
width: 20px;
height: 20px;
border-radius: 50%;
cursor: pointer;
}
</style>
</head>
<body class="flex flex-col h-screen">
<div class="p-4 bg-gray-100">
<input type="text" id="search" placeholder="Filtrer les lieux..." class="w-full p-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
</div>
<div id="map" class="flex-grow"></div>
<div id="info" class="bg-white p-4 overflow-y-auto">
<h2 id="pointTitle" class="text-xl font-bold mb-2"></h2>
<p id="pointText"></p>
</div>
<script>
const genevaPoints = [
{ id: 1, lon: 6.1263512, lat: 46.1724392, text: "Ciclissimo: Bicycle shop" },
{ id: 2, lon: 6.1462724, lat: 46.192623, text: "Bike Store: Bicycle shop" },
{ id: 3, lon: 6.1412889, lat: 46.2104853, text: "Association Genèveroule (Montbrillant): Bicycle rental and repair" },
{ id: 4, lon: 6.1492379, lat: 46.211157, text: "Hot Point: Bicycle shop" },
{ id: 5, lon: 6.1431435, lat: 46.1937367, text: "Bike Passion: Bicycle...