Wall, VKAPI: More geolocation suppor

This commit is contained in:
veselcraft 2023-08-03 23:24:26 +03:00
parent b9932eefdf
commit 2428e3cf5e
No known key found for this signature in database
GPG key ID: AED66BC1AC628A4E
5 changed files with 29 additions and 1 deletions

View file

@ -111,6 +111,18 @@ final class Wall extends VKAPIRequestHandler
]; ];
} }
$geo = [];
if($post->getGeolocation()) {
$geoarray = $post->getGeolocationByArray();
$geo = [
"coordinates" => $geoarray[0] . " " . $geoarray[1],
"showmap" => 1,
"type" => "point"
];
}
$items[] = (object)[ $items[] = (object)[
"id" => $post->getVirtualId(), "id" => $post->getVirtualId(),
"from_id" => $from_id, "from_id" => $from_id,
@ -128,6 +140,7 @@ final class Wall extends VKAPIRequestHandler
"is_explicit" => $post->isExplicit(), "is_explicit" => $post->isExplicit(),
"attachments" => $attachments, "attachments" => $attachments,
"post_source" => $post_source, "post_source" => $post_source,
"geo" => $geo,
"comments" => (object)[ "comments" => (object)[
"count" => $post->getCommentsCount(), "count" => $post->getCommentsCount(),
"can_post" => 1 "can_post" => 1

View file

@ -181,6 +181,18 @@ class Post extends Postable
return $this->getRecord()->geolocation; return $this->getRecord()->geolocation;
} }
function getGeolocationAsArray(): ?array {
$location = $this->getRecord()->geolocation;
if(is_null($location)) return null;
preg_match('/^((\-?|\+?)?\d+(\.\d+)?),\s*((\-?|\+?)?\d+(\.\d+)?)$/', $location, $location_array);
$latitude = floatval($location_array[1]);
$longitude = floatval($location_array[4]);
return array($latitude, $longitude);
}
function getMapEmbed(): ?string { function getMapEmbed(): ?string {
$location = $this->getRecord()->geolocation; $location = $this->getRecord()->geolocation;
if(is_null($location)) return null; if(is_null($location)) return null;

View file

@ -268,7 +268,7 @@ async function openMapDialog(id)
{ {
let iframe = await API.Wall.getMapIframe(id) let iframe = await API.Wall.getMapIframe(id)
let frame = MessageBox("Геолокация", iframe, [tr("close")], [Function.noop]); let frame = MessageBox(tr("geolocation"), iframe, [tr("close")], [Function.noop]);
document.querySelector(".ovk-diag-body").style.padding = "10px" document.querySelector(".ovk-diag-body").style.padding = "10px"
} }

View file

@ -214,6 +214,8 @@
"reply" = "Reply"; "reply" = "Reply";
"geolocation" = "Geolocation";
/* Friends */ /* Friends */
"friends" = "Friends"; "friends" = "Friends";

View file

@ -191,6 +191,7 @@
"version_incompatibility" = "Не удалось отобразить это вложение. Возможно, база данных несовместима с текущей версией OpenVK."; "version_incompatibility" = "Не удалось отобразить это вложение. Возможно, база данных несовместима с текущей версией OpenVK.";
"graffiti" = "Граффити"; "graffiti" = "Граффити";
"reply" = "Ответить"; "reply" = "Ответить";
"geolocation" = "Геолокация";
/* Friends */ /* Friends */