Skip to content

Commit df83a28

Browse files
authored
Merge pull request #303 from vcooley/feature/ios-icon-cache
feat(ios): add icon cache for icons with equivalent hues
2 parents 1c668b0 + 19dffd7 commit df83a28

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/map-view.ios.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,17 @@ export class Marker extends MarkerBase {
602602
private _alpha = 1;
603603
private _visible = true;
604604

605+
private static cachedColorIcons: { [hue: number]: any } = {}
606+
607+
private static getIconForColor(hue: number) {
608+
const hueKey = hue.toFixed(8);
609+
if (!Marker.cachedColorIcons[hueKey]) {
610+
const icon = GMSMarker.markerImageWithColor(UIColor.colorWithHueSaturationBrightnessAlpha(hue, 1, 1, 1));
611+
Marker.cachedColorIcons[hueKey] = icon;
612+
}
613+
return Marker.cachedColorIcons[hueKey];
614+
}
615+
605616
constructor() {
606617
super();
607618
this._ios = GMSMarker.new();
@@ -668,7 +679,7 @@ export class Marker extends MarkerBase {
668679

669680
this._color = value;
670681
if (this._color) {
671-
this._ios.icon = GMSMarker.markerImageWithColor(UIColor.colorWithHueSaturationBrightnessAlpha(this._color / 360, 1, 1, 1));
682+
this._ios.icon = Marker.getIconForColor(this._color / 360);
672683
} else {
673684
this._ios.icon = null;
674685
}

0 commit comments

Comments
 (0)