From 0724236e2e7c6eb3b068216dcbc083867e3ed5aa Mon Sep 17 00:00:00 2001 From: Krivchikov Dmitry Date: Mon, 7 Mar 2016 23:41:36 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A2=D0=BE=D0=BB=D1=8C=D0=BA=D0=BE=20=D1=87?= =?UTF-8?q?=D0=B0=D1=81=D1=82=D0=B8=D1=87=D0=BD=D0=B0=D1=8F=20=D0=BF=D0=BE?= =?UTF-8?q?=D0=B4=D0=B3=D1=80=D1=83=D0=B7=D0=BA=D0=B0=20=D1=82=D0=BE=D1=87?= =?UTF-8?q?=D0=B5=D0=BA=20=D0=BD=D0=B0=20=D0=BA=D0=B0=D1=80=D1=82=D0=B5.?= =?UTF-8?q?=20=D0=94=D0=BB=D1=8F=20=D1=81=D0=BB=D1=83=D1=87=D0=B0=D0=B9?= =?UTF-8?q?=D0=BD=D0=BE=D0=B9=20=D1=82=D0=BE=D1=87=D0=BA=D0=B8=20=D0=BF?= =?UTF-8?q?=D0=BE=D0=B4=D0=B3=D1=80=D1=83=D0=B6=D0=B0=D0=B5=D0=BC=20=D0=B2?= =?UTF-8?q?=D1=81=D1=91=20=D0=B8=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0?= =?UTF-8?q?=D0=B5=D0=BC=20=D0=BF=D0=BE-=D1=81=D1=82=D0=B0=D1=80=D0=BE?= =?UTF-8?q?=D0=BC=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/js/app.js | 11 +++++++---- public/js/map.js | 34 ++++++++++++++++++++++++++++++---- 2 files changed, 37 insertions(+), 8 deletions(-) diff --git a/public/js/app.js b/public/js/app.js index 6ecc2d9..644ebf5 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -169,6 +169,11 @@ function getTime() { function showRandomPoint() { + if (typeof fullLoad == 'undefined') { + initPoints(); + fullLoad = true; + } + roundIndex = Math.floor(Math.random() * points.length); runner = 0; for (var key in points) @@ -199,11 +204,9 @@ function initCategories() }); } - if (isAdmin == 0) { - initPoints(true); - } + initPoints(true); - return initPoints(); + return true; } /** diff --git a/public/js/map.js b/public/js/map.js index 9d4a39c..e586c6d 100644 --- a/public/js/map.js +++ b/public/js/map.js @@ -108,6 +108,7 @@ function init(lat, lng) { { document.title = 'Лучшие выходные — это выходные в путешествии! – wikipoints.ru'; history.pushState({lat: myMap.getCenter().lat, lng: myMap.getCenter().lng, zoom: myMap.getZoom()}, document.title, "/?lat=" + myMap.getCenter().lat + "&lng=" + myMap.getCenter().lng + "&zoom=" + myMap.getZoom()); + loadPointsInBounds(); } if (status == statusMovingInHistory) @@ -206,10 +207,6 @@ function initPoints(useBounds) myMap.addLayer(markers); myMap.addLayer(markersPlus); - if (useBounds == true) { - return true; - } - if (getURLParameter('point') != 'null') { if (getURLParameter('point') == 'random') @@ -241,6 +238,35 @@ function initPoints(useBounds) return true; } +function loadPointsInBounds() +{ + bounds = myMap.getBounds(); + bounds = Array(bounds._northEast.lat,bounds._northEast.lng,bounds._southWest.lat,bounds._southWest.lng) + + $.ajax({ + url: "/json/points/", + data: { + bounds: bounds + }, + success: function (data) { + for(var i=0; i < data.length; i++) { + if (typeof points[data[i].id] == 'undefined') { + if (data[i]['categoryId'] == 24 || data[i]['categoryId'] == 25) { + markersPlus.addLayer(constructPoint(data[i])); + } else { + markers.addLayer(constructPoint(data[i])); + } + } + } + myMap.addLayer(markers); + myMap.addLayer(markersPlus); + } + }); + + return true; +} + + /** * Показывает баллун для точки. Если данных для точки нет, то подгружает их с сервера. * @param {type} id