Skip to content

Commit

Permalink
Signing commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Joseph Ahern committed Sep 10, 2024
1 parent 447491b commit 44cbc07
Showing 1 changed file with 23 additions and 24 deletions.
47 changes: 23 additions & 24 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,52 +63,51 @@ export function createCustomMarkerClass(api: typeof google.maps): ICustomMarkerC

if (point) {
this.element.style.position = "absolute";
const height = this.element.offsetHeight;
const width = this.element.offsetWidth;
let x: number, y: number;
let transformX: string, transformY: string;

switch (this.opts.anchorPoint) {
case "TOP_CENTER":
x = point.x - width / 2;
y = point.y;
transformX = "-50%";
transformY = "-100%";
break;
case "BOTTOM_CENTER":
x = point.x - width / 2;
y = point.y - height;
transformX = "-50%";
transformY = "0";
break;
case "LEFT_CENTER":
x = point.x;
y = point.y - height / 2;
transformX = "-100%";
transformY = "-50%";
break;
case "RIGHT_CENTER":
x = point.x - width;
y = point.y - height / 2;
transformX = "0";
transformY = "-50%";
break;
case "TOP_LEFT":
x = point.x;
y = point.y;
transformX = "-100%";
transformY = "-100%";
break;
case "TOP_RIGHT":
x = point.x - width;
y = point.y;
transformX = "0";
transformY = "-100%";
break;
case "BOTTOM_LEFT":
x = point.x;
y = point.y - height;
transformX = "-100%";
transformY = "0";
break;
case "BOTTOM_RIGHT":
x = point.x - width;
y = point.y - height;
transformX = "0";
transformY = "0";
break;
default:
// "center"
x = point.x - width / 2;
y = point.y - height / 2;
transformX = "-50%";
transformY = "-50%";
}

this.element.style.left = x + "px";
this.element.style.top = y + "px";
this.element.style.left = point.x + (this.opts.offsetX || 0) + "px";
this.element.style.top = point.y + (this.opts.offsetY || 0) + "px";
// eslint-disable-next-line prettier/prettier
this.element.style.transform = `translateX(${this.opts.offsetX || 0}px) translateY(${this.opts.offsetY || 0}px)`;
this.element.style.transform = `translateX(${transformX}) translateY(${transformY})`;

if (this.opts.zIndex) {
this.element.style.zIndex = this.opts.zIndex.toString();
Expand Down

0 comments on commit 44cbc07

Please sign in to comment.