Make tileCenter return the point actually at the tile center

Then use css to adjust the position of the debug div
This commit is contained in:
Bryan Housel
2017-07-03 16:03:41 -04:00
parent b9df6df03f
commit 1f826851b2
2 changed files with 5 additions and 4 deletions
+3
View File
@@ -2484,6 +2484,7 @@ img.tile {
}
.tile-label-debug {
font-size: 10px;
background: rgba(0, 0, 0, 0.7);
color: #fff;
position: absolute;
@@ -2491,6 +2492,8 @@ img.tile {
padding: 5px;
border-radius: 3px;
z-index: 2;
margin-left: -50px;
margin-top: -20px;
transform-origin:0 0;
-ms-transform-origin:0 0;
+2 -4
View File
@@ -151,11 +151,9 @@ export function rendererTileLayer(context) {
function tileCenter(d) {
var _ts = tileSize * Math.pow(2, z - d[2]);
var scale = tileSizeAtZoom(d, z);
// FIXME: this scale * tileSize/number stuff is hacky, and more for displaying the debug text.
// It's not really the center of the tile, but it is guaranteed to be somewhere in the tile.
return [
((d[0] * _ts) - tileOrigin[0] + pixelOffset[0] + scale * (tileSize / 4)),
((d[1] * _ts) - tileOrigin[1] + pixelOffset[1] + scale * (tileSize / 2))
((d[0] * _ts) - tileOrigin[0] + pixelOffset[0] + (_ts / 2)),
((d[1] * _ts) - tileOrigin[1] + pixelOffset[1] + (_ts / 2))
];
}