Skip to content

Commit

Permalink
Migrate to mapbox #997 - Fix route palnning (again...), Fix icon in c…
Browse files Browse the repository at this point in the history
…ase the address is not the site origin, Fix end of recording color refresh.
  • Loading branch information
HarelM committed Apr 25, 2019
1 parent b4616ca commit 4673591
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export class RouteEditRouteInteraction {
}

private handleMove = (event: MapMouseEvent) => {
if (this.mouseDownPoint != null &&
if (this.mouseDownPoint != null && event.point &&
Math.abs((this.mouseDownPoint.x - event.point.x) + (this.mouseDownPoint.y - event.point.y)) < DRAG_PIXEL_TOLERANCE) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { LocalStorage } from "ngx-store";
import { first } from "rxjs/operators";
import { NgRedux } from "@angular-redux/store";
import { MapComponent } from "ngx-mapbox-gl";
import { MapMouseEvent } from "mapbox-gl";

import { ResourcesService } from "../services/resources.service";
import { BaseMapComponent } from "./base-map.component";
Expand All @@ -18,6 +17,7 @@ import { AddTraceAction } from "../reducres/traces.reducer";
import { StopRecordingAction, StartRecordingAction } from "../reducres/route-editing-state.reducer";
import { RouteData, ApplicationState, LatLngAlt, DataContainer, TraceVisibility } from "../models/models";
import { SpatialService } from "../services/spatial.service";
import { Urls } from "../urls";

interface ILocationInfo extends LatLngAlt {
radius: number;
Expand Down Expand Up @@ -61,7 +61,7 @@ export class LocationComponent extends BaseMapComponent {
this.updateLocationFeatureCollection(null);

this.host.load.subscribe(() => {
this.host.mapInstance.loadImage(window.location.href + "content/gps-direction.png", (_, img) => {
this.host.mapInstance.loadImage(Urls.baseAddress + "/content/gps-direction.png", (_, img) => {
this.host.mapInstance.addImage("gps-direction", img);
});
this.host.mapInstance.on("dragstart",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ export class RoutesComponent extends BaseMapComponent implements AfterViewInit {
public editingRoute: GeoJSON.FeatureCollection<GeoJSON.LineString | GeoJSON.Point>;
public routesGeoJson: GeoJSON.FeatureCollection<GeoJSON.LineString | GeoJSON.Point>;

private routes: RouteData[];

constructor(resources: ResourcesService,
private readonly selectedRouteService: SelectedRouteService,
private readonly routeEditPoiInteraction: RouteEditPoiInteraction,
Expand All @@ -56,25 +58,29 @@ export class RoutesComponent extends BaseMapComponent implements AfterViewInit {
type: "FeatureCollection",
features: []
};
this.routes = [];
this.setHoverFeature(null);
this.routeEditRouteInteraction.onRoutePointClick.subscribe(this.handleRoutePointClick);
this.routeEditRouteInteraction.onPointerMove.subscribe(this.setHoverFeature);
this.routes$.subscribe(this.handleRoutesChanges);
// HM TODO: fix the color when recording finishes.
this.routeRecordingId$.subscribe(() => { });
this.routeRecordingId$.subscribe(this.buildFeatureCollections);

}

private handleRoutesChanges = (routes: RouteData[]) => {
this.routes = routes;
this.snappingService.enable(this.isEditMode());
if (!this.isEditMode()) {
this.setHoverFeature(null);
}
this.setInteractionAccordingToState();
this.buildFeatureCollections();
}

private buildFeatureCollections = () => {
let features = [];
let editingFeatures = [];

for (let route of routes) {
for (let route of this.routes) {
if (route.state === "Hidden") {
continue;
}
Expand Down

0 comments on commit 4673591

Please sign in to comment.