File tree Expand file tree Collapse file tree 1 file changed +23
-24
lines changed Expand file tree Collapse file tree 1 file changed +23
-24
lines changed Original file line number Diff line number Diff line change @@ -63,52 +63,51 @@ export function createCustomMarkerClass(api: typeof google.maps): ICustomMarkerC
63
63
64
64
if ( point ) {
65
65
this . element . style . position = "absolute" ;
66
- const height = this . element . offsetHeight ;
67
- const width = this . element . offsetWidth ;
68
- let x : number , y : number ;
66
+ let transformX : string , transformY : string ;
67
+
69
68
switch ( this . opts . anchorPoint ) {
70
69
case "TOP_CENTER" :
71
- x = point . x - width / 2 ;
72
- y = point . y ;
70
+ transformX = "-50%" ;
71
+ transformY = "-100%" ;
73
72
break ;
74
73
case "BOTTOM_CENTER" :
75
- x = point . x - width / 2 ;
76
- y = point . y - height ;
74
+ transformX = "-50%" ;
75
+ transformY = "0" ;
77
76
break ;
78
77
case "LEFT_CENTER" :
79
- x = point . x ;
80
- y = point . y - height / 2 ;
78
+ transformX = "-100%" ;
79
+ transformY = "-50%" ;
81
80
break ;
82
81
case "RIGHT_CENTER" :
83
- x = point . x - width ;
84
- y = point . y - height / 2 ;
82
+ transformX = "0" ;
83
+ transformY = "-50%" ;
85
84
break ;
86
85
case "TOP_LEFT" :
87
- x = point . x ;
88
- y = point . y ;
86
+ transformX = "-100%" ;
87
+ transformY = "-100%" ;
89
88
break ;
90
89
case "TOP_RIGHT" :
91
- x = point . x - width ;
92
- y = point . y ;
90
+ transformX = "0" ;
91
+ transformY = "-100%" ;
93
92
break ;
94
93
case "BOTTOM_LEFT" :
95
- x = point . x ;
96
- y = point . y - height ;
94
+ transformX = "-100%" ;
95
+ transformY = "0" ;
97
96
break ;
98
97
case "BOTTOM_RIGHT" :
99
- x = point . x - width ;
100
- y = point . y - height ;
98
+ transformX = "0" ;
99
+ transformY = "0" ;
101
100
break ;
102
101
default :
103
102
// "center"
104
- x = point . x - width / 2 ;
105
- y = point . y - height / 2 ;
103
+ transformX = "-50%" ;
104
+ transformY = "-50%" ;
106
105
}
107
106
108
- this . element . style . left = x + "px" ;
109
- this . element . style . top = y + "px" ;
107
+ const xPos = point . x + ( this . opts . offsetX || 0 ) + "px" ;
108
+ const yPos = point . y + ( this . opts . offsetY || 0 ) + "px" ;
110
109
// eslint-disable-next-line prettier/prettier
111
- this . element . style . transform = `translateX(${ this . opts . offsetX || 0 } px ) translateY(${ this . opts . offsetY || 0 } px )` ;
110
+ this . element . style . transform = `translateX(${ transformX } ) translateX( ${ xPos } ) translateY(${ transformY } ) translateY( ${ yPos } )` ;
112
111
113
112
if ( this . opts . zIndex ) {
114
113
this . element . style . zIndex = this . opts . zIndex . toString ( ) ;
You can’t perform that action at this time.
0 commit comments