mirror of
https://github.com/openvk/openvk
synced 2024-12-22 16:42:32 +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)[
|
$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
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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"
|
||||||
}
|
}
|
||||||
|
|
|
@ -214,6 +214,8 @@
|
||||||
|
|
||||||
"reply" = "Reply";
|
"reply" = "Reply";
|
||||||
|
|
||||||
|
"geolocation" = "Geolocation";
|
||||||
|
|
||||||
/* Friends */
|
/* Friends */
|
||||||
|
|
||||||
"friends" = "Friends";
|
"friends" = "Friends";
|
||||||
|
|
|
@ -191,6 +191,7 @@
|
||||||
"version_incompatibility" = "Не удалось отобразить это вложение. Возможно, база данных несовместима с текущей версией OpenVK.";
|
"version_incompatibility" = "Не удалось отобразить это вложение. Возможно, база данных несовместима с текущей версией OpenVK.";
|
||||||
"graffiti" = "Граффити";
|
"graffiti" = "Граффити";
|
||||||
"reply" = "Ответить";
|
"reply" = "Ответить";
|
||||||
|
"geolocation" = "Геолокация";
|
||||||
|
|
||||||
/* Friends */
|
/* Friends */
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue