<!DOCTYPE html>
<html>
<head>
    <title>Konum Bilgisi Alma</title>
    <script>
        function getLocation() {
            if (navigator.geolocation) {
                navigator.geolocation.getCurrentPosition(showPosition);
            } else {
                alert("Tarayıcınız konumlandırmayı desteklemiyor.");
            }
        }

        function showPosition(position) {
            var latitude = position.coords.latitude;
            var longitude = position.coords.longitude;
            document.getElementById("latitude").value = latitude;
            document.getElementById("longitude").value = longitude;
            document.getElementById("locationForm").submit();
        }
    </script>
</head>
<body onload="getLocation()">
    <form id="locationForm" method="post" action="process_location.php">
        <input type="hidden" id="latitude" name="latitude" value="">
        <input type="hidden" id="longitude" name="longitude" value="">
    </form>
</body>
</html>
function reverseGeocode($latitude, $longitude) {
  $url = 'https://maps.googleapis.com/maps/api/geocode/json?latlng=' . $latitude . ',' . $longitude . '&key=YOUR_API_KEY';
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  $response = curl_exec($ch);
  curl_close($ch);
  $data = json_decode($response, true);
  if ($data['status'] == 'OK') {
    $result = array();
    foreach ($data['results'][0]['address_components'] as $component) {
      if (in_array('locality', $component['types'])) {
        $result['city'] = $component['long_name'];
      }
      if (in_array('administrative_area_level_1', $component['types'])) {
        $result['state'] = $component['long_name'];
      }
      if (in_array('administrative_area_level_2', $component['types'])) {
        $result['district'] = $component['long_name'];
      }
      if (in_array('neighborhood', $component['types'])) {
        $result['neighborhood'] = $component['long_name'];
      }
    }
    return $result;
  } else {
    return false;
  }
}

// Kullanıcının konum bilgilerini alın
$latitude = $_POST['latitude'];$longitude = $_POST['longitude'];

// Google Maps Geocoding API'ye sorgu gönderin
$locationData = reverseGeocode($latitude, $longitude);

// Sonuçları kullanın
if ($locationData) {
  $city = $locationData['city'];
  $state = $locationData['state'];
  $district = $locationData['district'];
  $neighborhood = $locationData['neighborhood'];
}
chatgpt ile yazdırdım, tek yapmanız gereken html dosyasındaki olayı direkt olarak ajax yada fetch ile php dosyasına post etmeniz ek olarak maps api keyi girmeniz yeterli