FIX-FIX вроде поправил клики по маркерам и перемещение по истории
This commit is contained in:
parent
ab7c821713
commit
feb28994a9
|
|
@ -160,7 +160,7 @@ function constructPoint(data)
|
||||||
[data['lat'], data['lng']], {icon: icon, title: data['name'], id: id, categoryId: data['categoryId']}
|
[data['lat'], data['lng']], {icon: icon, title: data['name'], id: id, categoryId: data['categoryId']}
|
||||||
).on('click', function (e) {
|
).on('click', function (e) {
|
||||||
if (!(id in pointsSources)) {
|
if (!(id in pointsSources)) {
|
||||||
showInfo(e.target.options.id);
|
showInfo(e.target.options.id, true);
|
||||||
} else {
|
} else {
|
||||||
history.pushState({pointId: id}, document.title, "/?point=" + e.target.options.id);
|
history.pushState({pointId: id}, document.title, "/?point=" + e.target.options.id);
|
||||||
document.title = e.target.options.title;
|
document.title = e.target.options.title;
|
||||||
|
|
@ -213,12 +213,13 @@ function initPoints()
|
||||||
* @param {type} id
|
* @param {type} id
|
||||||
* @returns {Boolean}
|
* @returns {Boolean}
|
||||||
*/
|
*/
|
||||||
function showInfo(id)
|
function showInfo(id, mapClick)
|
||||||
{
|
{
|
||||||
if (!(id in points)) {
|
if (!(id in points)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mapClick = Boolean(mapClick !== undefined && mapClick === true); // true если это клик по маркеру на карте
|
||||||
marker = points[id];
|
marker = points[id];
|
||||||
if (!(id in pointsSources))
|
if (!(id in pointsSources))
|
||||||
{
|
{
|
||||||
|
|
@ -227,15 +228,15 @@ function showInfo(id)
|
||||||
url: "/json/point/id/" + id,
|
url: "/json/point/id/" + id,
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
pointsSources[id] = data;
|
pointsSources[id] = data;
|
||||||
drawInfoPopup(id)
|
drawInfoPopup(id, true)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
drawInfoPopup(id);
|
drawInfoPopup(id, !mapClick);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function drawInfoPopup(id) {
|
function drawInfoPopup(id, showPopup) {
|
||||||
data = pointsSources[id];
|
data = pointsSources[id];
|
||||||
if (typeof (data.images) == 'object')
|
if (typeof (data.images) == 'object')
|
||||||
{
|
{
|
||||||
|
|
@ -285,12 +286,15 @@ function drawInfoPopup(id) {
|
||||||
bounds = myMap.getBounds();
|
bounds = myMap.getBounds();
|
||||||
diff = (bounds._northEast.lat - bounds._southWest.lat) / 4;
|
diff = (bounds._northEast.lat - bounds._southWest.lat) / 4;
|
||||||
myMap.setView([points[id]._latlng.lat + diff, points[id]._latlng.lng], myMap.getZoom());
|
myMap.setView([points[id]._latlng.lat + diff, points[id]._latlng.lng], myMap.getZoom());
|
||||||
marker.openPopup();
|
|
||||||
|
if (showPopup) {
|
||||||
|
marker.openPopup();
|
||||||
|
}
|
||||||
|
|
||||||
history.pushState({pointId: id}, document.title, "/?point=" + id);
|
history.pushState({pointId: id}, document.title, "/?point=" + id);
|
||||||
document.title = marker.options.title;
|
document.title = marker.options.title;
|
||||||
});
|
});
|
||||||
window.event.stopPropagation();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue