Skip to content

Commit

Permalink
fix: more offset adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
foosint committed Jan 29, 2024
1 parent 53f2d84 commit eb01299
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,16 @@ class MapViewer {
// tooltip offset
// depends on amplifier set and side
let offsetY = ih / 2; // fallback
let offsetX = iw / 1.5;
if (unitSide === 'ua') {
offsetY = hasAmplifier ? ih / 1.7 : ih / 2.25;
offsetX = iw / 1.5;
offsetY = hasAmplifier ? ih / 6 : 0;
} else if (unitSide === 'ru') {
offsetY = hasAmplifier ? ih / 1.6 : ih / 1.6;
offsetX = hasAmplifier ? iw / 2 : iw / 1.5;
offsetY = hasAmplifier ? ih / 8 : 0;
}
const tooltipOffset: number[] = [0, offsetY];
// const tooltipOffset: number[] = [0, offsetY];
const tooltipOffset: number[] = [offsetX, offsetY];

// return width & height
return { iw, ih, tooltipOffset };
Expand Down Expand Up @@ -430,7 +434,7 @@ class MapViewer {
const showPermanent = false;
const tooltipOptions: any = {
permanent: showPermanent,
direction: 'bottom',
direction: 'auto',
className: 'unit-labels',
};

Expand All @@ -439,6 +443,7 @@ class MapViewer {
unitLayer.eachLayer((layer: any) => {
const { properties } = layer.feature;
const { unitName, offset } = properties;
// tooltipOptions.offset = offset;
tooltipOptions.offset = offset;
// console.log('bindtooltip', tooltipOptions);
layer.bindTooltip(unitName, tooltipOptions);
Expand Down

0 comments on commit eb01299

Please sign in to comment.