Skip to content

Commit

Permalink
Fix: correzione geolocalizzazione sede
Browse files Browse the repository at this point in the history
  • Loading branch information
BeppeJQ committed Oct 31, 2024
1 parent 0b1e4d7 commit c1fe61e
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions modules/anagrafiche/src/Sede.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,17 +120,17 @@ protected function geolocalizzazione()
$this->lat = $data[0]->lat;
$this->lng = $data[0]->lon;
} elseif (setting('Gestore mappa') == 'Google Maps') {
$curl = new CurlHttpAdapter();
$geocoder = new GoogleMaps($curl, 'IT-it', null, true, $google);
$apiKey = setting('Google Maps API key per Tecnici');
$url = 'https://maps.googleapis.com/maps/api/geocode/json?address='.$indirizzo.'&key='.$apiKey;

// Ricerca indirizzo
$address = $geocoder->geocode($indirizzo)->first();
$coordinates = $address->getCoordinates();
$response = file_get_contents($url);
$data = json_decode($response, true);

// Salvataggio informazioni
$this->gaddress = $data[0]->display_name;
$this->lat = $coordinates->getLatitude();
$this->lng = $coordinates->getLongitude();
if ($data['status'] == 'OK') {
$this->lat = $data['results'][0]['geometry']['location']['lat'];
$this->lng = $data['results'][0]['geometry']['location']['lng'];
$this->gaddress = $data['results'][0]['formatted_address'];
}
}
}
}
Expand Down

0 comments on commit c1fe61e

Please sign in to comment.