|
1 |
| -import fastdom from "fastdom"; |
2 | 1 | type ICustomMarkerInterface = google.maps.OverlayView & {
|
3 | 2 | getPosition(): google.maps.LatLng | null;
|
4 | 3 | getVisible(): boolean;
|
@@ -63,62 +62,57 @@ export function createCustomMarkerClass(api: typeof google.maps): ICustomMarkerC
|
63 | 62 | const point = overlayProjection?.fromLatLngToDivPixel(this.getPosition());
|
64 | 63 |
|
65 | 64 | if (point) {
|
66 |
| - const element = this.element; |
67 |
| - fastdom.measure(() => { |
68 |
| - const height = element.offsetHeight; |
69 |
| - const width = element.offsetWidth; |
70 |
| - let x: number, y: number; |
71 |
| - switch (this.opts.anchorPoint) { |
72 |
| - case "TOP_CENTER": |
73 |
| - x = point.x - width / 2; |
74 |
| - y = point.y; |
75 |
| - break; |
76 |
| - case "BOTTOM_CENTER": |
77 |
| - x = point.x - width / 2; |
78 |
| - y = point.y - height; |
79 |
| - break; |
80 |
| - case "LEFT_CENTER": |
81 |
| - x = point.x; |
82 |
| - y = point.y - height / 2; |
83 |
| - break; |
84 |
| - case "RIGHT_CENTER": |
85 |
| - x = point.x - width; |
86 |
| - y = point.y - height / 2; |
87 |
| - break; |
88 |
| - case "TOP_LEFT": |
89 |
| - x = point.x; |
90 |
| - y = point.y; |
91 |
| - break; |
92 |
| - case "TOP_RIGHT": |
93 |
| - x = point.x - width; |
94 |
| - y = point.y; |
95 |
| - break; |
96 |
| - case "BOTTOM_LEFT": |
97 |
| - x = point.x; |
98 |
| - y = point.y - height; |
99 |
| - break; |
100 |
| - case "BOTTOM_RIGHT": |
101 |
| - x = point.x - width; |
102 |
| - y = point.y - height; |
103 |
| - break; |
104 |
| - default: |
105 |
| - // "center" |
106 |
| - x = point.x - width / 2; |
107 |
| - y = point.y - height / 2; |
108 |
| - } |
109 |
| - |
110 |
| - fastdom.mutate(() => { |
111 |
| - element.style.position = "absolute"; |
112 |
| - element.style.left = x + "px"; |
113 |
| - element.style.top = y + "px"; |
114 |
| - // eslint-disable-next-line prettier/prettier |
115 |
| - element.style.transform = `translateX(${this.opts.offsetX || 0}px) translateY(${this.opts.offsetY || 0}px)`; |
116 |
| - |
117 |
| - if (this.opts.zIndex) { |
118 |
| - element.style.zIndex = this.opts.zIndex.toString(); |
119 |
| - } |
120 |
| - }); |
121 |
| - }); |
| 65 | + this.element.style.position = "absolute"; |
| 66 | + const height = this.element.offsetHeight; |
| 67 | + const width = this.element.offsetWidth; |
| 68 | + let x: number, y: number; |
| 69 | + switch (this.opts.anchorPoint) { |
| 70 | + case "TOP_CENTER": |
| 71 | + x = point.x - width / 2; |
| 72 | + y = point.y; |
| 73 | + break; |
| 74 | + case "BOTTOM_CENTER": |
| 75 | + x = point.x - width / 2; |
| 76 | + y = point.y - height; |
| 77 | + break; |
| 78 | + case "LEFT_CENTER": |
| 79 | + x = point.x; |
| 80 | + y = point.y - height / 2; |
| 81 | + break; |
| 82 | + case "RIGHT_CENTER": |
| 83 | + x = point.x - width; |
| 84 | + y = point.y - height / 2; |
| 85 | + break; |
| 86 | + case "TOP_LEFT": |
| 87 | + x = point.x; |
| 88 | + y = point.y; |
| 89 | + break; |
| 90 | + case "TOP_RIGHT": |
| 91 | + x = point.x - width; |
| 92 | + y = point.y; |
| 93 | + break; |
| 94 | + case "BOTTOM_LEFT": |
| 95 | + x = point.x; |
| 96 | + y = point.y - height; |
| 97 | + break; |
| 98 | + case "BOTTOM_RIGHT": |
| 99 | + x = point.x - width; |
| 100 | + y = point.y - height; |
| 101 | + break; |
| 102 | + default: |
| 103 | + // "center" |
| 104 | + x = point.x - width / 2; |
| 105 | + y = point.y - height / 2; |
| 106 | + } |
| 107 | + |
| 108 | + this.element.style.left = x + "px"; |
| 109 | + this.element.style.top = y + "px"; |
| 110 | + // eslint-disable-next-line prettier/prettier |
| 111 | + this.element.style.transform = `translateX(${this.opts.offsetX || 0}px) translateY(${this.opts.offsetY || 0}px)`; |
| 112 | + |
| 113 | + if (this.opts.zIndex) { |
| 114 | + this.element.style.zIndex = this.opts.zIndex.toString(); |
| 115 | + } |
122 | 116 | }
|
123 | 117 | }
|
124 | 118 |
|
|
0 commit comments