| Current Path : /home/ataenra/www/ATA/INTRANET/Admin/Gestion_ACC/ |
| Current File : /home/ataenra/www/ATA/INTRANET/Admin/Gestion_ACC/PV.php |
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Google Maps Géolocalisation</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: Arial, sans-serif;
background-color: #f1f5f9;
min-height: 100vh;
padding: 1rem;
}
.container {
max-width: 1200px;
margin: 0 auto;
}
.card {
background: white;
border-radius: 0.5rem;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
overflow: hidden;
}
.header {
background: #2563eb;
color: white;
padding: 1rem;
}
.header h1 {
font-size: 1.5rem;
display: flex;
align-items: center;
gap: 0.5rem;
}
.error-message {
margin-top: 0.5rem;
background: #1d4ed8;
padding: 0.5rem;
border-radius: 0.25rem;
font-size: 0.875rem;
}
.content {
padding: 1rem;
display: grid;
grid-template-columns: 2fr 1fr;
gap: 1rem;
}
#map {
height: 500px;
border-radius: 0.5rem;
overflow: hidden;
}
.coordinates {
background: #f8fafc;
padding: 1rem;
border-radius: 0.5rem;
}
.coordinates h2 {
font-size: 1.25rem;
margin-bottom: 1rem;
color: #1e293b;
}
.coordinate-box {
background: white;
padding: 0.75rem;
border-radius: 0.375rem;
margin-bottom: 0.5rem;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.coordinate-box p:first-child {
color: #64748b;
font-size: 0.875rem;
margin-bottom: 0.25rem;
}
.coordinate-box p:last-child {
font-family: monospace;
font-size: 1.125rem;
}
@media (max-width: 768px) {
.content {
grid-template-columns: 1fr;
}
}
</style>
<script
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBJK0GVBASHQUIFbE3NudYEWFtodD9bM_s&callback=initMap&libraries=places&v=weekly"
defer
></script>
</head>
<body>
<div class="container">
<div style="display: none">
<input
id="pac-input"
class="controls"
type="text"
placeholder="Adresse du site"
/>
</div>
<div id="map"></div>
<div id="infowindow-content">
<span id="place-name" class="title"></span><br />
<strong>Place ID:</strong> <span id="place-id"></span><br />
<span id="place-address"></span>
</div>
</div>
<script>
function initMap() {
const map = new google.maps.Map(document.getElementById("map"), {
center: { lat: 51, lng: 2.5 },
zoom: 8,
});
const input = document.getElementById("pac-input");
// Specify just the place data fields that you need.
const autocomplete = new google.maps.places.Autocomplete(input, {
fields: ["place_id", "geometry", "formatted_address", "name"],
});
autocomplete.bindTo("bounds", map);
map.controls[google.maps.ControlPosition.TOP_LEFT].push(input);
const infowindow = new google.maps.InfoWindow();
const infowindowContent = document.getElementById("infowindow-content");
infowindow.setContent(infowindowContent);
const marker = new google.maps.Marker({ map: map });
marker.addListener("click", () => {
infowindow.open(map, marker);
});
autocomplete.addListener("place_changed", () => {
infowindow.close();
const place = autocomplete.getPlace();
if (!place.geometry || !place.geometry.location) {
return;
}
if (place.geometry.viewport) {
map.fitBounds(place.geometry.viewport);
} else {
map.setCenter(place.geometry.location);
map.setZoom(17);
}
// Set the position of the marker using the place ID and location.
// @ts-ignore This should be in @typings/googlemaps.
marker.setPlace({
placeId: place.place_id,
location: place.geometry.location,
});
marker.setVisible(true);
infowindowContent.children.namedItem("place-name").textContent = place.name;
infowindowContent.children.namedItem("place-id").textContent =
place.place_id;
infowindowContent.children.namedItem("place-address").textContent =
place.formatted_address;
infowindow.open(map, marker);
});
}
window.initMap = initMap;
</script>
<script async defer src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBJK0GVBASHQUIFbE3NudYEWFtodD9bM_s&callback=initMap"></script>
</body>
</html>