Skip to content

Commit

Permalink
Improve UX:- Make track non-clickable,- Make bat clickable to select …
Browse files Browse the repository at this point in the history
…the track,- Add rollover text on bats.
  • Loading branch information
vicb committed Jul 15, 2020
1 parent e5c3b15 commit 0ae9bbf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
6 changes: 4 additions & 2 deletions frontend/src/viewer/components/gm-line.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { customElement, LitElement, property, PropertyValues } from 'lit-element';
import { customElement, LitElement, property } from 'lit-element';

import { RuntimeTrack } from '../../../../common/track';
import { trackColor } from '../logic/map';
Expand All @@ -22,7 +22,7 @@ export class GmLineElement extends LitElement {
line: google.maps.Polyline | null = null;
maskLine: google.maps.Polyline | null = null;

shouldUpdate(changedProperties: PropertyValues): boolean {
shouldUpdate(): boolean {
if (this.map && this.track) {
const path: { lat: number; lng: number }[] = [];
const track = this.track;
Expand All @@ -35,6 +35,7 @@ export class GmLineElement extends LitElement {

if (!this.maskLine) {
this.maskLine = new google.maps.Polyline({
clickable: false,
map: this.map,
strokeColor: '#fff',
strokeOpacity: 0.6,
Expand All @@ -46,6 +47,7 @@ export class GmLineElement extends LitElement {

if (!this.line) {
this.line = new google.maps.Polyline({
clickable: false,
map: this.map,
strokeOpacity: 1.0,
strokeWeight: 2,
Expand Down
16 changes: 11 additions & 5 deletions frontend/src/viewer/components/gm-marker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { customElement, LitElement, property } from 'lit-element';
import { connect } from 'pwa-helpers';

import { RuntimeTrack } from '../../../../common/track';
import { setCurrentTrack } from '../actions/map';
import { trackColor } from '../logic/map';
import { sampleAt } from '../logic/math';
import { tsOffsets } from '../selectors/map';
Expand Down Expand Up @@ -38,16 +39,21 @@ export class GmMarkerElement extends connect(store)(LitElement) {

shouldUpdate(): boolean {
if (this.map && this.track) {
const track = this.track;
if (!this.marker) {
this.marker = new google.maps.Marker({
map: this.map,
clickable: false,
clickable: true,
title: track.name,
});
google.maps.event.addListener(this.marker, 'click', () => {
store.dispatch(setCurrentTrack(this.index));
});
}
const track = this.track;
const lat = sampleAt(track.fixes.ts, track.fixes.lat, [this.timestamp + this.tsOffsets[this.index]])[0];
const lon = sampleAt(track.fixes.ts, track.fixes.lon, [this.timestamp + this.tsOffsets[this.index]])[0];
const alt = sampleAt(track.fixes.ts, track.fixes.alt, [this.timestamp + this.tsOffsets[this.index]])[0];
const timestamp = this.timestamp + this.tsOffsets[this.index];
const lat = sampleAt(track.fixes.ts, track.fixes.lat, [timestamp])[0];
const lon = sampleAt(track.fixes.ts, track.fixes.lon, [timestamp])[0];
const alt = sampleAt(track.fixes.ts, track.fixes.alt, [timestamp])[0];
const scale = (50 * (alt - track.minAlt)) / (track.maxAlt - track.minAlt) + 20;
this.marker.setPosition({ lat, lng: lon });
this.marker.setIcon({
Expand Down

0 comments on commit 0ae9bbf

Please sign in to comment.