Skip to content

Commit

Permalink
Fix div by 0
Browse files Browse the repository at this point in the history
  • Loading branch information
vicb committed Mar 29, 2024
1 parent 0de234e commit aee5350
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
3 changes: 1 addition & 2 deletions apps/fxc-front/src/app/components/2d/adv-marker-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ export class AdvancedMarkerElement extends LitElement {
disconnectedCallback() {
super.disconnectedCallback();
google.maps.event.clearInstanceListeners(this.marker_);
// setTimeout is needed otherwise the marker isn't removed.
setTimeout(() => (this.marker_.map = null), 0);
this.marker_.map = null;
}

render() {
Expand Down
8 changes: 4 additions & 4 deletions apps/fxc-front/src/app/components/2d/marker-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { RootState, store } from '../../redux/store';
import { setCurrentTrackId } from '../../redux/track-slice';

import './adv-marker-element';
import { round } from '@flyxc/common';

const INACTIVE_OPACITY = 0.5;

Expand Down Expand Up @@ -81,10 +82,9 @@ export class MarkerElement extends connect(store)(LitElement) {
const { lat, lon, alt } = sel.getTrackLatLonAlt(store.getState())(timeSec, this.track) as common.LatLonAlt;
const altAboveMin = (alt ?? 0) - this.track.minAlt;
const altDelta = this.track.maxAlt - this.track.minAlt;
const scale = (50 * altAboveMin) / altDelta + 20;
// todo
this.path.setAttribute('transform', `scale(${scale / 512})`);
this.path.setAttribute('stroke-width', `${2 / (scale / 512)}`);
const scale = 20 + (50 * altAboveMin) / Math.max(altDelta, 1);
this.path.setAttribute('transform', `scale(${round(scale / 512, 4)})`);
this.path.setAttribute('stroke-width', `${round(2 / (scale / 512), 4)}`);

let label = '';
if (this.displayLabels) {
Expand Down

0 comments on commit aee5350

Please sign in to comment.