Added better distance measuring
This commit is contained in:
parent
105d1bb27d
commit
4c3c233f06
3
src/app/models/map.ts
Normal file
3
src/app/models/map.ts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
export interface Map {
|
||||||
|
name: string
|
||||||
|
}
|
8
src/app/models/marker.ts
Normal file
8
src/app/models/marker.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
export class Marker {
|
||||||
|
latitude: number;
|
||||||
|
longitude: number;
|
||||||
|
name: string;
|
||||||
|
color: string;
|
||||||
|
notes: string;
|
||||||
|
icon: string;
|
||||||
|
}
|
@ -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);
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Remove google maps branding
|
// Remove google maps branding
|
||||||
|
agm-map {
|
||||||
a[href^="http://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}
|
a[href^="https://maps.google.com/maps"]{display:none !important}
|
||||||
|
|
||||||
@ -25,6 +26,12 @@ a[href^="https://maps.google.com/maps"]{display:none !important}
|
|||||||
|
|
||||||
.gmnoprint div {
|
.gmnoprint div {
|
||||||
background: none !important;
|
background: none !important;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
button[title="Close"] {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.mat-padding-0 {
|
.mat-padding-0 {
|
||||||
|
Loading…
Reference in New Issue
Block a user