FIX - непоказывание попапа при перемещении по истории, при клике в маршруте и так далее

This commit is contained in:
Krivchikov Dmitry 2015-06-04 01:11:52 +03:00
parent 5a6408c059
commit ab7c821713
1 changed files with 71 additions and 62 deletions

View File

@ -159,7 +159,12 @@ function constructPoint(data)
points[id] = L.marker(
[data['lat'], data['lng']], {icon: icon, title: data['name'], id: id, categoryId: data['categoryId']}
).on('click', function (e) {
if (!(id in pointsSources)) {
showInfo(e.target.options.id);
} else {
history.pushState({pointId: id}, document.title, "/?point=" + e.target.options.id);
document.title = e.target.options.title;
}
});
return points[id];
@ -210,15 +215,28 @@ function initPoints()
*/
function showInfo(id)
{
marker = points[id];
if (!(id in points)) {
return false;
}
if (!(id in points) || marker.options.description == undefined)
marker = points[id];
if (!(id in pointsSources))
{
marker.bindPopup("<h3>" + marker.options['title'] + "</h3><img src='/img/loading.gif' style='height: 16px;' /> Загрузка...").openPopup();
$.ajax({
url: "/json/point/id/" + id,
success: function (data) {
pointsSources[id] = data;
drawInfoPopup(id)
}
});
} else {
drawInfoPopup(id);
}
}
function drawInfoPopup(id) {
data = pointsSources[id];
if (typeof (data.images) == 'object')
{
photos = '<div style="position: relative;">';
@ -264,25 +282,16 @@ function showInfo(id)
marker.bindPopup(marker.options.description, {maxWidth: maxWidth, minWidth: 400, maxHeight: maxHeight});
markers.zoomToShowLayer(marker, function () {
bounds = myMap.getBounds();
diff = (bounds._northEast.lat - bounds._southWest.lat) / 4;
myMap.setView([points[id]._latlng.lat + diff, points[id]._latlng.lng], myMap.getZoom());
marker.openPopup();
bounds = myMap.getBounds();
diff = (bounds._northEast.lat - bounds._southWest.lat) / 4;
myMap.setView([points[id]._latlng.lat + diff, points[id]._latlng.lng], myMap.getZoom());
history.pushState({pointId: id}, document.title, "/?point=" + id);
document.title = data.name;
document.title = marker.options.title;
});
}
});
} else {
bounds = myMap.getBounds();
diff = (bounds._northEast.lat - bounds._southWest.lat) / 4;
myMap.setView([points[id]._latlng.lat + diff, points[id]._latlng.lng], myMap.getZoom());
history.pushState({pointId: id}, document.title, "/?point=" + id);
document.title = points[id].options.title;
}
window.event.stopPropagation();
return true;
}
function setLayer(name)