JSFiddle - React, Tailwind, and code Playground
HTML
<!DOCTYPE html>
<html>
<head>
<title>Route Finder</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.9.4/leaflet.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.9.4/leaflet.js"></script>
<style>
.container {
max-width: 800px;
margin: 20px auto;
padding: 20px;
font-family: system-ui, -apple-system, sans-serif;
}
.input-group {
margin-bottom: 15px;
}
input {
width: 100%;
padding: 8px;
margin-bottom: 10px;
border: 1px solid #ccc;
border-radius: 4px;
}
button {
background-color: #0066cc;
color: white;
padding: 10px 20px;
border: none;
border-radius: 4px;
cursor: pointer;
}
button:disabled {
background-color: #cccccc;
}
#map {
height: 400px;
margin: 20px 0;
border-radius: 8px;
}
.error {
color: red;
margin: 10px 0;
padding: 10px;
background-color: #ffebee;
border-radius: 4px;
}
.route-info {
margin-top: 15px;
padding: 15px;
background-color: #f5f5f5;
border-radius: 4px;
}
</style>
</head>
<body>
<div class="container">
<h1>Route Finder</h1>
<div class="input-group">
<input type="password" id="apiKey" placeholder="OpenRouteService API Key" />
<input type="text" id="startLocation" placeholder="Starting location" />
<input type="text" id="endLocation" placeholder="Destination" />
<button id="findRoute" disabled>Find Route</button>
</div>
<div id="error" class="error" style="display: none;"></div>
<div id="map"></div>
<div...