From f402d46db8d3e924ce6e25c281957b19eb1c3e04 Mon Sep 17 00:00:00 2001 From: piratefinn Date: Wed, 27 Sep 2017 17:46:25 +0100 Subject: [PATCH] Added API changes --- src/app/dashboard/map.component.html | 8 +++---- src/app/dashboard/map.component.ts | 34 +++++++++------------------- src/app/providers/api-service.ts | 2 +- 3 files changed, 16 insertions(+), 28 deletions(-) diff --git a/src/app/dashboard/map.component.html b/src/app/dashboard/map.component.html index 04d7d73..1c408a4 100644 --- a/src/app/dashboard/map.component.html +++ b/src/app/dashboard/map.component.html @@ -24,12 +24,12 @@ (idle)="viewBoundsChanged($event)"> + [latitude]="m.latitude" + [longitude]="m.longitude" + [label]="m.name[0]"> - {{m.label}} + {{m.name}} diff --git a/src/app/dashboard/map.component.ts b/src/app/dashboard/map.component.ts index 5acc512..71faed0 100644 --- a/src/app/dashboard/map.component.ts +++ b/src/app/dashboard/map.component.ts @@ -15,24 +15,7 @@ export class MapComponent implements OnInit { dataReceived: string = 'yes'; - markers = [ - { - lat: 54.0466, - lng: -2.8007, - label: 'A', - - }, - { - lat: 54.0453, - lng: -2.83, - label: 'B' - }, - { - lat: 54.0563, - lng: -2.8279, - label: 'C' - } - ] + markers: Array<{latitude: number, longitude: number, name: string}>; map: any; @@ -56,14 +39,19 @@ export class MapComponent implements OnInit { console.log(resp.getSouthWest().lat()); console.log(resp.getSouthWest().lng()); const mapData = { - north_east_lat: resp.getNorthEast().lat(), - north_east_lng: resp.getNorthEast().lng(), - south_west_lat: resp.getSouthWest().lat(), - south_west_lng: resp.getSouthWest().lng() - }; + north_east: { + latitude: resp.getNorthEast().lat(), + longitude: resp.getNorthEast().lng() + }, + south_west: { + latitude: resp.getSouthWest().lat(), + longitude: resp.getSouthWest().lng() + }, + } this.api.getMapData(mapData).subscribe( result => { this.dataReceived = 'yes'; + this.markers = result.suppliers; }, error => { // this.dataReceived = 'no'; diff --git a/src/app/providers/api-service.ts b/src/app/providers/api-service.ts index 4bc910d..37919e3 100644 --- a/src/app/providers/api-service.ts +++ b/src/app/providers/api-service.ts @@ -268,7 +268,7 @@ export class ApiService { public getMapData(data) { data.session_key = this.sessionKey; return this.http.post( - this.apiUrl + '/map', + this.apiUrl + '/v1/suppliers/location', data ).map( response => response.json() ); }