diff --git a/Web/Models/sql/get-nearest-posts.tsql b/Web/Models/sql/get-nearest-posts.tsql
index d844a3ac..5da7faa8 100644
--- a/Web/Models/sql/get-nearest-posts.tsql
+++ b/Web/Models/sql/get-nearest-posts.tsql
@@ -3,8 +3,9 @@ SELECT *,
POW(69.1 * (? - geo_lat), 2) +
POW(69.1 * (? - geo_lon) * COS(RADIANS(geo_lat)), 2)
) AS distance
-FROM Posts
+FROM posts
WHERE id <> ?
+AND FROM_UNIXTIME(created) >= DATE_SUB(NOW(), INTERVAL 1 MONTH)
HAVING distance < 1 AND distance IS NOT NULL
ORDER BY distance
LIMIT 25;
diff --git a/Web/static/js/al_wall.js b/Web/static/js/al_wall.js
index f28bd997..418b89c9 100644
--- a/Web/static/js/al_wall.js
+++ b/Web/static/js/al_wall.js
@@ -275,7 +275,7 @@ async function initGeo(tid) {
$(`#post-buttons${tid} .post-has-geo`).text(`${tr("geotag")}: ${marker.name}`);
$(`#post-buttons${tid} .post-has-geo`).show();
}), Function.noop]);
-
+
const element = document.getElementById('osm-map');
element.style = 'height: 600px;';
@@ -378,12 +378,8 @@ function getNearPosts(owner_id, virtual_id) {
});
}
-function openNearPosts(posts) {
- console.log(posts);
- let MsgBody = "";
-
- posts.posts.forEach((post) => {
- MsgBody += `
+function getPostPopup(post) {
+ return `
@@ -416,9 +412,44 @@ function openNearPosts(posts) {
`;
- });
+}
- if (posts.need_count) MsgBody += "
Показаны первые 25 постов"
+function openNearPosts(posts) {
+ if (posts.posts.length > 0) {
+ let MsgTxt = "";
+ MsgTxt += "
Показано последние 25 постов за месяц";
- MessageBox("Ближайшие посты", MsgBody, ["OK"], [Function.noop]);
-}
\ No newline at end of file
+ MessageBox("Ближайшие посты", MsgTxt, ["OK"], [Function.noop]);
+
+ let element = document.getElementById('osm-map');
+ element.style = 'height: 600px;';
+
+ let markerLayers = L.layerGroup();
+ let map = L.map(element, {attributionControl: false});
+
+ markerLayers.addTo(map);
+
+ let markersBounds = [];
+
+ posts.posts.forEach((post) => {
+ let marker = L.marker(L.latLng(post.geo.lat, post.geo.lng)).addTo(map);
+ marker.bindPopup(getPostPopup(post));
+ markerLayers.addLayer(marker);
+ markersBounds.push(marker.getLatLng());
+ })
+
+ let bounds = L.latLngBounds(markersBounds);
+ map.fitBounds(bounds);
+
+ L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
+ attribution: '© OpenStreetMap contributors'
+ }).addTo(map);
+
+ $(".ovk-diag-cont").width('50%');
+ setTimeout(function () {
+ map.invalidateSize()
+ }, 100);
+ } else {
+ MessageBox("Ближайшие посты", "Нет ближайших постов :(", ["OK"], [Function.noop]);
+ }
+}