mirror of
https://github.com/openvk/openvk
synced 2024-11-14 02:59:12 +03:00
Wall, VKAPI: More geolocation suppor
This commit is contained in:
parent
b9932eefdf
commit
2428e3cf5e
5 changed files with 29 additions and 1 deletions
|
@ -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)[
|
||||
"id" => $post->getVirtualId(),
|
||||
"from_id" => $from_id,
|
||||
|
@ -128,6 +140,7 @@ final class Wall extends VKAPIRequestHandler
|
|||
"is_explicit" => $post->isExplicit(),
|
||||
"attachments" => $attachments,
|
||||
"post_source" => $post_source,
|
||||
"geo" => $geo,
|
||||
"comments" => (object)[
|
||||
"count" => $post->getCommentsCount(),
|
||||
"can_post" => 1
|
||||
|
|
|
@ -181,6 +181,18 @@ class Post extends Postable
|
|||
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 {
|
||||
$location = $this->getRecord()->geolocation;
|
||||
if(is_null($location)) return null;
|
||||
|
|
|
@ -268,7 +268,7 @@ async function openMapDialog(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"
|
||||
}
|
||||
|
|
|
@ -214,6 +214,8 @@
|
|||
|
||||
"reply" = "Reply";
|
||||
|
||||
"geolocation" = "Geolocation";
|
||||
|
||||
/* Friends */
|
||||
|
||||
"friends" = "Friends";
|
||||
|
|
|
@ -191,6 +191,7 @@
|
|||
"version_incompatibility" = "Не удалось отобразить это вложение. Возможно, база данных несовместима с текущей версией OpenVK.";
|
||||
"graffiti" = "Граффити";
|
||||
"reply" = "Ответить";
|
||||
"geolocation" = "Геолокация";
|
||||
|
||||
/* Friends */
|
||||
|
||||
|
|
Loading…
Reference in a new issue