diff --git a/app/Http/Controllers/Interfaces/IController.php b/app/Http/Controllers/Interfaces/IController.php new file mode 100644 index 0000000..f72988e --- /dev/null +++ b/app/Http/Controllers/Interfaces/IController.php @@ -0,0 +1,11 @@ + + */ + private string $yandex_url = "https://api-maps.yandex.ru/2.1"; + private string $yandex_key = "9ea0bde8-b886-4620-9eab-c354727b634c"; + + private array $apiParams; + + + public function index(int $id) + { + $this->apiParams = array( + "apikey" => $this->yandex_key, + "lang" =>"ru_RU", + ); + + $apiCall = $this->createApiCall(); + + return $this->render('yandex_map') + ->with('apiCall', $apiCall) + ->with('yandex_maps_id', $id); + } + + public function getPlace(int $id) + { + $place = Place::find($id); + [ $x, $y ] = explode("|",$place->Gps); + + return response()->json([ + 'x' => $x, 'y' => $y + ]); + } + + private function createApiCall(): string + { + $tmp = []; + + foreach($this->apiParams as $k => $v) { + $tmp[] = sprintf("%s=%s", $k, $v); + } + + return sprintf("%s/?%s", $this->yandex_url, implode("&", $tmp)); + } +} +?> diff --git a/app/Models/ORM/Place.php b/app/Models/ORM/Place.php new file mode 100644 index 0000000..324af64 --- /dev/null +++ b/app/Models/ORM/Place.php @@ -0,0 +1,18 @@ + + +
+