Account for the width of open panes when centering the map on issues

This commit is contained in:
Quincy Morgan
2019-05-10 11:33:59 -04:00
parent 1bbd496dfe
commit 7a6949aa2e
3 changed files with 17 additions and 2 deletions
+1 -1
View File
@@ -114,7 +114,7 @@ export function coreValidator(context) {
if (extent) {
var setZoom = Math.max(context.map().zoom(), 19);
context.map().centerZoomEase(extent.center(), setZoom);
context.map().unobscuredCenterZoomEase(extent.center(), setZoom);
// select the first entity
if (issue.entityIds && issue.entityIds.length) {
+15
View File
@@ -738,6 +738,21 @@ export function rendererMap(context) {
return map;
};
map.unobscuredCenterZoomEase = function(loc, zoom) {
var offset = map.unobscuredOffset();
var locPx = projection(loc);
var offsetLocPx = [locPx[0] + offset[0], locPx[1] + offset[1]];
var offsetLoc = projection.invert(offsetLocPx);
map.centerZoomEase(offsetLoc, zoom);
};
map.unobscuredOffset = function() {
var openPane = d3_select('.map-panes .map-pane.shown');
if (!openPane.empty()) {
return [openPane.node().offsetWidth/2, 0];
}
return [0, 0];
};
map.zoom = function(z2) {
if (!arguments.length) {
+1 -1
View File
@@ -102,7 +102,7 @@ export function uiEntityIssues(context) {
var extent = d.extent(context.graph());
if (extent) {
var setZoom = Math.max(context.map().zoom(), 19);
context.map().centerZoomEase(extent.center(), setZoom);
context.map().unobscuredCenterZoomEase(extent.center(), setZoom);
}
});