Skip to content

Commit

Permalink
Downscale if no small icon
Browse files Browse the repository at this point in the history
  • Loading branch information
matthew44-mappable committed Apr 8, 2024
1 parent d612f8d commit fc0de04
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
6 changes: 3 additions & 3 deletions example/default-markers/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ export const MARKER_LOCATIONS: MMapDefaultMarkerProps[] = [
{coordinates: [CENTER[0], CENTER[1] + STEP / 2]},
{coordinates: [CENTER[0] + STEP, CENTER[1] + STEP / 2], size: 'micro'},
// airport icon
{iconName: 'airport', coordinates: [CENTER[0] - STEP, CENTER[1] - STEP / 2], size: 'normal'},
{iconName: 'airport', coordinates: [CENTER[0], CENTER[1] - STEP / 2]},
{iconName: 'airport', coordinates: [CENTER[0] + STEP, CENTER[1] - STEP / 2], size: 'micro'},
{iconName: 'viewpoint', coordinates: [CENTER[0] - STEP, CENTER[1] - STEP / 2], size: 'normal'},
{iconName: 'viewpoint', coordinates: [CENTER[0], CENTER[1] - STEP / 2]},
{iconName: 'viewpoint', coordinates: [CENTER[0] + STEP, CENTER[1] - STEP / 2], size: 'micro'},
// color
{color: 'steelblue', coordinates: [CENTER[0] - STEP, CENTER[1] + STEP], size: 'normal'},
{color: 'steelblue', coordinates: [CENTER[0], CENTER[1] + STEP]},
Expand Down
7 changes: 5 additions & 2 deletions src/MMapDefaultMarker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,13 @@ export class MMapDefaultMarker extends mappable.MMapComplexEntity<MMapDefaultMar
}

private _getIcon(): string {
if (this._props.size === 'micro') {
if (this._props.size === 'micro' || this._props.iconName === undefined) {
return '';
}
return this._props.iconName !== undefined ? icons[this._props.iconName][this._props.size] : '';
if (icons[this._props.iconName][this._props.size]) {
return icons[this._props.iconName][this._props.size];
}
return icons[this._props.iconName].normal.replace(/<svg/, '$& style="transform:scale(calc(10/24)"');
}

private _getColor(): ThemesColor {
Expand Down

0 comments on commit fc0de04

Please sign in to comment.