Added better distance measuring

This commit is contained in:
ztimson 2019-07-22 12:58:17 -04:00
parent 105d1bb27d
commit 4c3c233f06
4 changed files with 34 additions and 17 deletions

3
src/app/models/map.ts Normal file
View File

@ -0,0 +1,3 @@
export interface Map {
name: string
}

8
src/app/models/marker.ts Normal file
View File

@ -0,0 +1,8 @@
export class Marker {
latitude: number;
longitude: number;
name: string;
color: string;
notes: string;
icon: string;
}

View File

@ -113,26 +113,25 @@ export class MapComponent {
let distance = distanceInM(first.lat, first.lng, coords.lat, coords.lng); let distance = distanceInM(first.lat, first.lng, coords.lat, coords.lng);
let marker = new google.maps.Marker({ let info = new google.maps.InfoWindow({
map: this.mapApi, content: distance >= 1000 ? `${Math.round(distance / 100) / 10} km` : `${Math.round(distance)} m`,
icon: null, position: {lat: (first.lat + coords.lat) / 2, lng: (first.lng + coords.lng) / 2}
position: {lat: (first.lat + coords.lat) / 2, lng: (first.lng + coords.lng) / 2},
label: distance >= 1000 ? `${Math.round(distance / 100) / 10} km` : `${Math.round(distance)} m`
}); });
info.open(this.mapApi);
google.maps.event.addListener(line, 'click', () => { google.maps.event.addListener(line, 'click', () => {
if(this.menu[1][3].enabled) { if(this.menu[1][3].enabled) {
line.setMap(null); line.setMap(null);
marker.setMap(null); info.setMap(null);
} }
}) });
google.maps.event.addListener(marker, 'click', () => { google.maps.event.addListener(info, 'click', () => {
if(this.menu[1][3].enabled) { if(this.menu[1][3].enabled) {
line.setMap(null); line.setMap(null);
marker.setMap(null); info.setMap(null);
} }
}) });
} }
}) })
} }

View File

@ -16,15 +16,22 @@ body {
} }
// Remove google maps branding // Remove google maps branding
a[href^="http://maps.google.com/maps"]{display:none !important} agm-map {
a[href^="https://maps.google.com/maps"]{display:none !important} a[href^="http://maps.google.com/maps"]{display:none !important}
a[href^="https://maps.google.com/maps"]{display:none !important}
.gmnoprint a, .gmnoprint span, .gm-style-cc { .gmnoprint a, .gmnoprint span, .gm-style-cc {
display:none; display: none;
} }
.gmnoprint div { .gmnoprint div {
background:none !important; background: none !important;
}
button[title="Close"] {
display: none !important;
}
} }
.mat-padding-0 { .mat-padding-0 {