diff --git a/README.md b/README.md index fb19aa76a4da1f794b8b84c59b8acce0cc8c1a33..b2aa21bbb4ef5b083fc7e02cb51af1ab3798af6a 100644 --- a/README.md +++ b/README.md @@ -73,7 +73,7 @@ Connection settings ``` - More objects can be added to the `"object": []` - There are special colours for objects. Config: [MarkerColorList](src/environments/environment.ts) - - topic `ipos/client/way` + - topic `ipos/client/waypoint` - new way points - ```json [ diff --git a/src/app/components/map/map.component.ts b/src/app/components/map/map.component.ts index 200622b01e28b3e7e30ba966c23333aacf97cb69..9401b9810650178482efc283120880f51a590da7 100644 --- a/src/app/components/map/map.component.ts +++ b/src/app/components/map/map.component.ts @@ -68,12 +68,14 @@ export class MapComponent implements OnInit { }); - // --- Agent way points - this.subsWayPoint = this._mqttService.observe('ipos/client/way').subscribe((message: IMqttMessage) => { + // --- Agent waypoints + this.subsWayPoint = this._mqttService.observe('ipos/client/waypoint').subscribe((message: IMqttMessage) => { try { let points: WayPoint[] = <WayPoint[]>JSON.parse(message.payload.toString()) - - console.log(points) + + if (!(Array.isArray(points))) { + points = [points] + } points.forEach(wayPoint => { if (isWayPoint(wayPoint)) { @@ -143,21 +145,21 @@ export class MapComponent implements OnInit { registerWayPoint(wayPoint: WayPoint) { // empty position if (wayPoint.position==undefined) { - console.log("Error: empty position.") + console.log("Error: empty waypoint position.") return } // empty position if (Object.values(wayPoint.position).every((e)=>{e==undefined})) { - console.log("Error: empty point.") + console.log("Error: empty position.") return; } let key = wayPoint.agentId // --- Marker config - let serialNum = Object.keys(this.markOverlays).indexOf(key) - var markerConf = getMarkerConfig(serialNum) + // let serialNum = Object.keys(this.markOverlays).indexOf(key) // ref to markers + // var markerConf = getMarkerConfig(serialNum) // --- Layer on the map if (!(key in this.wayPointsOverlays)) { @@ -173,14 +175,13 @@ export class MapComponent implements OnInit { } // --- Marker - let markerDesc = `<p> \ - <h4>Way point</h4> + <h3>Waypoint</h3> <strong>Agent</strong>: ${wayPoint.agentId} <br>\ <strong>Time</strong>: ${wayPoint.time} <br> </p>` - let marker = L.circleMarker(globPos, {radius: 5, color: markerConf.color}).bindPopup(markerDesc).openPopup(); + let marker = L.circleMarker(globPos, {radius: 5, color: "#d97b16"}).bindPopup(markerDesc).openPopup(); marker.addTo(this.wayPointsOverlays[key]) } diff --git a/src/app/model/base-model.ts b/src/app/model/base-model.ts index 19520bacfe649904cfcecc60ca91b1a9a329c2b4..0597e70a7a9a92d2212d12096a3b415733396cc5 100644 --- a/src/app/model/base-model.ts +++ b/src/app/model/base-model.ts @@ -114,11 +114,11 @@ export function isAgent(obj: any): obj is Agent { // --- Way points export interface WayPoint { - "agentId": string - "agentType"?: AgentType - "publisher"?: string - "position": Position - "time": string + agentId: string + agentType?: AgentType + publisher?: string + position: Position + time: string }