Только частичная подгрузка точек на карте. Для случайной точки подгружаем всё и работаем по-старому
This commit is contained in:
parent
0942e34e25
commit
0724236e2e
|
|
@ -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);
|
||||
}
|
||||
|
||||
return initPoints();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue