Skip to content

Commit adcc590

Browse files
authored
Merge pull request #146 from OutSystems/ROU-4592
ROU-4592: fixing google maps imprecision with markers
2 parents 311a9a8 + bb36b91 commit adcc590

2 files changed

Lines changed: 23 additions & 8 deletions

File tree

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
2+
namespace OSFramework.Maps.Helper {
3+
/**
4+
* Validates if value is a valid number.
5+
*
6+
* @export
7+
* @param {unknown} value
8+
* @return {*} {boolean}
9+
*/
10+
export function IsValidNumber(value: unknown): boolean {
11+
return !isNaN(value as number);
12+
}
13+
}

src/Providers/Maps/Google/Marker/Marker.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,23 @@ namespace Provider.Maps.Google.Marker {
3434
} else {
3535
try {
3636
let scaledSize: google.maps.Size;
37+
//Explicit conversion to number - related with ROU-4592 - as google will behave differently depending on the type
38+
//of the input. Before, in runtime, the input was of type string.
39+
const height = Number(this.config.iconHeight);
40+
const width = Number(this.config.iconWidth);
3741
// If the size of the icon is defined by a valid width and height, use those values
3842
// Else If nothing is passed or the icon size has the width or the height equal to 0, use the full image size
3943
if (
40-
this.config.iconWidth > 0 &&
41-
this.config.iconHeight > 0
44+
OSFramework.Maps.Helper.IsValidNumber(height) &&
45+
OSFramework.Maps.Helper.IsValidNumber(width) &&
46+
height > 0 && width > 0
4247
) {
43-
scaledSize = new google.maps.Size(
44-
this.config.iconWidth,
45-
this.config.iconHeight
46-
);
48+
scaledSize = new google.maps.Size(width, height);
4749
}
4850
// Update the icon using the previous configurations
4951
const icon = {
50-
url,
51-
scaledSize
52+
url: url,
53+
size: scaledSize
5254
};
5355
// Set the icon to the Marker provider
5456
this.provider.setIcon(icon);

0 commit comments

Comments
 (0)