forked from La_Bureautique/zeg1jeux
35 lines
662 B
PHP
35 lines
662 B
PHP
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>Geoloc</title>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
<body>
|
|
|
|
|
|
<button onclick="getLocation()">Me géolocaliser</button>
|
|
|
|
<p id="result">
|
|
</p>
|
|
|
|
<script>
|
|
|
|
var result = document.getElementById('result');
|
|
|
|
function getLocation() {
|
|
|
|
if (navigator.geolocation) {
|
|
navigator.geolocation.getCurrentPosition(showPosition);
|
|
} else {
|
|
result.innerHTML = "Geolocation is not supported by this browser.";
|
|
}
|
|
}
|
|
|
|
function showPosition(position) {
|
|
|
|
result.innerHTML = "Latitude: " + position.coords.latitude +
|
|
"<br>Longitude: " + position.coords.longitude;
|
|
}
|
|
|
|
</script>
|
|
</body>
|
|
</html> |