Fixed deleting problems

This commit is contained in:
Zakary Timson 2019-08-31 17:02:28 -04:00
parent 20ae1708a9
commit eff9b213ed
2 changed files with 6 additions and 3 deletions

View File

@ -17,6 +17,7 @@ export interface MapSymbol {
symbol?: any;
latlng?: LatLng | LatLng[];
noDelete?: boolean;
noDeleteTool?: boolean;
noSelect?: boolean;
label?: string;
color?: string;

View File

@ -1,6 +1,6 @@
import {Component, HostListener, isDevMode, OnDestroy, OnInit} from "@angular/core";
import {PhysicsService} from "../../services/physics.service";
import {filter, finalize, flatMap, skip, take} from "rxjs/operators";
import {filter, finalize, skip, take} from "rxjs/operators";
import {MatBottomSheet, MatSnackBar} from "@angular/material";
import {CalibrateComponent} from "../../components/calibrate/calibrate.component";
import {ToolbarItem} from "../../models/toolbarItem";
@ -63,7 +63,7 @@ export class MapComponent implements OnDestroy, OnInit {
startDelete = () => {
this.sub = this.map.click.pipe(skip(1), filter(e => !!e.symbol)).subscribe(e => {
if (!!e.symbol && e.symbol.noDelete) return;
if (!!e.symbol && e.symbol.noDeleteTool) return;
this.syncService.delete(e.symbol)
});
};
@ -244,11 +244,12 @@ export class MapComponent implements OnDestroy, OnInit {
if (!this.position) this.center({lat: pos.latitude, lng: pos.longitude});
if (this.positionMarker.arrow) this.map.delete(this.positionMarker.arrow);
if (this.positionMarker.circle) this.map.delete(this.positionMarker.circle);
this.syncService.addMyLocation({latlng: {lat: pos.latitude, lng: pos.longitude}, label: this.name});
this.syncService.addMyLocation({latlng: {lat: pos.latitude, lng: pos.longitude}, label: this.name, noDeleteTool: true});
this.positionMarker.arrow = this.map.newMarker({
latlng: {lat: pos.latitude, lng: pos.longitude},
noSelect: true,
noDelete: true,
noDeleteTool: true,
icon: 'arrow',
rotationAngle: pos.heading,
rotationOrigin: 'center'
@ -258,6 +259,7 @@ export class MapComponent implements OnDestroy, OnInit {
color: '#2873d8',
noSelect: true,
noDelete: true,
noDeleteTool: true,
radius: pos.accuracy,
interactive: false
});