Added API changes

This commit is contained in:
piratefinn 2017-09-27 17:46:25 +01:00
parent b59351addf
commit f402d46db8
3 changed files with 16 additions and 28 deletions

View file

@ -24,12 +24,12 @@
(idle)="viewBoundsChanged($event)"> (idle)="viewBoundsChanged($event)">
<agm-marker <agm-marker
*ngFor="let m of markers" *ngFor="let m of markers"
[latitude]="m.lat" [latitude]="m.latitude"
[longitude]="m.lng" [longitude]="m.longitude"
[label]="m.label"> [label]="m.name[0]">
<agm-info-window> <agm-info-window>
<strong>{{m.label}}</strong> <strong>{{m.name}}</strong>
</agm-info-window> </agm-info-window>
</agm-marker> </agm-marker>
</agm-map> </agm-map>

View file

@ -15,24 +15,7 @@ export class MapComponent implements OnInit {
dataReceived: string = 'yes'; dataReceived: string = 'yes';
markers = [ markers: Array<{latitude: number, longitude: number, name: string}>;
{
lat: 54.0466,
lng: -2.8007,
label: 'A',
},
{
lat: 54.0453,
lng: -2.83,
label: 'B'
},
{
lat: 54.0563,
lng: -2.8279,
label: 'C'
}
]
map: any; map: any;
@ -56,14 +39,19 @@ export class MapComponent implements OnInit {
console.log(resp.getSouthWest().lat()); console.log(resp.getSouthWest().lat());
console.log(resp.getSouthWest().lng()); console.log(resp.getSouthWest().lng());
const mapData = { const mapData = {
north_east_lat: resp.getNorthEast().lat(), north_east: {
north_east_lng: resp.getNorthEast().lng(), latitude: resp.getNorthEast().lat(),
south_west_lat: resp.getSouthWest().lat(), longitude: resp.getNorthEast().lng()
south_west_lng: resp.getSouthWest().lng() },
}; south_west: {
latitude: resp.getSouthWest().lat(),
longitude: resp.getSouthWest().lng()
},
}
this.api.getMapData(mapData).subscribe( this.api.getMapData(mapData).subscribe(
result => { result => {
this.dataReceived = 'yes'; this.dataReceived = 'yes';
this.markers = result.suppliers;
}, },
error => { error => {
// this.dataReceived = 'no'; // this.dataReceived = 'no';

View file

@ -268,7 +268,7 @@ export class ApiService {
public getMapData(data) { public getMapData(data) {
data.session_key = this.sessionKey; data.session_key = this.sessionKey;
return this.http.post( return this.http.post(
this.apiUrl + '/map', this.apiUrl + '/v1/suppliers/location',
data data
).map( response => response.json() ); ).map( response => response.json() );
} }