Pop up CV move errors.

This commit is contained in:
Dan Albert 2021-05-15 14:22:19 -07:00
parent 06dedf51aa
commit 95b107ffad

View File

@ -165,6 +165,7 @@ class ControlPoint {
this.cp.setDestination([destination.lat, destination.lng]).then((err) => { this.cp.setDestination([destination.lat, destination.lng]).then((err) => {
if (err) { if (err) {
console.log(`Could not set control point destination: ${err}`); console.log(`Could not set control point destination: ${err}`);
this.locationMarker().bindPopup(err).openPopup();
// Reset markers and paths on error. On success this happens when we get // Reset markers and paths on error. On success this happens when we get
// the destinationChanged signal from the backend. // the destinationChanged signal from the backend.
this.onDestinationChanged(); this.onDestinationChanged();
@ -203,14 +204,21 @@ class ControlPoint {
this.secondaryMarker.off("contextmenu"); this.secondaryMarker.off("contextmenu");
} }
locationMarker(dragging = false) {
return this.hasDestination() || dragging
? this.secondaryMarker
: this.primaryMarker;
}
destinationMarker() {
return this.hasDestination() ? this.primaryMarker : null;
}
attachTooltipsAndHandlers(dragging = false) { attachTooltipsAndHandlers(dragging = false) {
this.detachTooltipsAndHandlers(); this.detachTooltipsAndHandlers();
const zoom = map.getZoom(); const zoom = map.getZoom();
const locationMarker = const locationMarker = this.locationMarker(dragging);
this.hasDestination() || dragging const destinationMarker = this.destinationMarker();
? this.secondaryMarker
: this.primaryMarker;
const destinationMarker = this.hasDestination() ? this.primaryMarker : null;
locationMarker locationMarker
.bindTooltip(`<h3 style="margin: 0;">${this.cp.name}</h3>`, { .bindTooltip(`<h3 style="margin: 0;">${this.cp.name}</h3>`, {
permanent: zoom >= SHOW_BASE_NAME_AT_ZOOM, permanent: zoom >= SHOW_BASE_NAME_AT_ZOOM,