diff --git a/public/js/map.js b/public/js/map.js index 3353ee8..f6cb585 100644 --- a/public/js/map.js +++ b/public/js/map.js @@ -163,6 +163,8 @@ function initPoints() function showInfo(id) { marker = points[id]; + markers.zoomToShowLayer(marker,function() {}); + if (!(id in points) || marker.options.description == undefined) { marker.bindPopup("Загрузка...").openPopup(); @@ -193,12 +195,21 @@ function showInfo(id) marker.options.description = description; marker.bindPopup(marker.options.description, {maxWidth: 500, maxHeight: 300}).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({}, document.title, "/?point=" + id); } }); - } + } 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()); - myMap.setView(points[id]._latlng, myMap.getZoom()); - history.pushState({}, document.title, "/?point=" + id); + history.pushState({}, document.title, "/?point=" + id); + } return true; }