From c95cead06d71b39870b64b64f518f9b7167556cd Mon Sep 17 00:00:00 2001 From: Quincy Morgan Date: Fri, 24 May 2019 10:28:59 -0400 Subject: [PATCH] Fix bug where issues would not be properly centered if the map was not already at z19 (close #6384) --- modules/renderer/map.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/modules/renderer/map.js b/modules/renderer/map.js index 62c5eec88..1d74de9ef 100644 --- a/modules/renderer/map.js +++ b/modules/renderer/map.js @@ -739,14 +739,20 @@ export function rendererMap(context) { }; map.unobscuredCenterZoomEase = function(loc, zoom) { - var offset = map.unobscuredOffset(); - var locPx = projection(loc); + var offset = map.unobscuredOffsetPx(); + + var proj = geoRawMercator().transform(projection.transform()); // copy projection + // use the target zoom to calculate the offset center + proj.scale(geoZoomToScale(zoom, TILESIZE)); + + var locPx = proj(loc); var offsetLocPx = [locPx[0] + offset[0], locPx[1] + offset[1]]; - var offsetLoc = projection.invert(offsetLocPx); + var offsetLoc = proj.invert(offsetLocPx); + map.centerZoomEase(offsetLoc, zoom); }; - map.unobscuredOffset = function() { + map.unobscuredOffsetPx = function() { var openPane = d3_select('.map-panes .map-pane.shown'); if (!openPane.empty()) { return [openPane.node().offsetWidth/2, 0];