Skip to content

Commit

Permalink
Fix bug where issues would not be properly centered if the map was no…
Browse files Browse the repository at this point in the history
…t already at z19 (close #6384)
  • Loading branch information
quincylvania committed May 24, 2019
1 parent 2a08868 commit c95cead
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions modules/renderer/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down

0 comments on commit c95cead

Please sign in to comment.