EGOCMS  24.0
EGOTEC Content-Managament-System
Ego_Map.php
gehe zur Dokumentation dieser Datei
1 <?php
2 
3 class Ego_Map
4 {
10  public static function getLatLon (string $address): array {
11  require_once 'base/Ego_Http.php';
12  $http = new Ego_Http();
13  $http->get('https://nominatim.openstreetmap.org/search?' . http_build_query([
14  'q' => $address,
15  'format' => 'json',
16  'addressdetails' => 1
17  ]), [
18  'User-Agent' => $_SERVER['HTTP_USER_AGENT']
19  ]);
20 
21  if (!empty($http->json) && is_object($http->json[0])) {
22  return [
23  'lati' => $http->json[0]->lat,
24  'long' => $http->json[0]->lon
25  ];
26  }
27 
28  return [];
29  }
30 
38  public static function getAddress (float $lat, float $lon) {
39  require_once 'base/Ego_Http.php';
40  $http = new Ego_Http();
41  $http->get('https://nominatim.openstreetmap.org/reverse?' . str_replace(",",".", implode("&",[
42  "lat=$lat",
43  "lon=$lon",
44  'zoom=18',
45  'format=json',
46  'addressdetails=1'
47  ])),[
48  'User-Agent' => $_SERVER['HTTP_USER_AGENT']
49  ]);
50 
51  if (!empty($http->json)) {
52  return $http->json;
53  }
54 
55  return "";
56  }
57 }
static getLatLon(string $address)
Definition: Ego_Map.php:10
static getAddress(float $lat, float $lon)
Definition: Ego_Map.php:38