Answer the question
In order to leave comments, you need to log in
How to get json data for Yandex Maps during automatic update?
Good afternoon.
Several items (locations) are selected on the main page, and when going to the panel.php page, an array (1,2,3,5,10) of these locations is passed there. Panel.php contains the Yandex map script. Example:
var myMap,
geoObjects,
objectManager,
arr_id = '".$arr_id."',
arrp = JSON.parse('[' + arr_id + ']');
ymaps.ready(init);
function init()
{
myMap = new ymaps.Map('map', {
center: [".$last_gps."],
zoom: 14,
type: 'yandex#satellite'
}, {
searchControlProvider: 'yandex#search'
});
objectManager = new ymaps.ObjectManager({
clusterize: true,
gridSize: 32,
clusterDisableClickZoom: true
});
objectManager.objects.options.set('preset', 'islands#grayDotIcon');
objectManager.clusters.options.set('preset', 'islands#grayClusterIcons');
myMap.geoObjects.add(objectManager);
$.ajax({
url:'panel_json.php',
type: 'post',
dataType: 'json',
data: {arrp:arrp}
}).done(function(data) {
objectManager.add(data);
});
myMap.geoObjects.add(objectManager);
};
url:'json/data.json'
Answer the question
In order to leave comments, you need to log in
$(window).scroll(function () {
if ($(this).scrollTop() > высота_до_меню) {
$('.menu').addClass('.fixed');
} else {
$('.menu').removeClass('.fixed');
}
});
The problem was in connecting to the database + unoptimized sql query. In the connection to the database, instead of "localhost" I specified the IP address of the server (only the connection took ~ 1 sec of time), and split the request to the database to display records into two separate requests. As a result, the page load time dropped to ~10-20 ms.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question