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)">
<agm-marker
*ngFor="let m of markers"
[latitude]="m.lat"
[longitude]="m.lng"
[label]="m.label">
[latitude]="m.latitude"
[longitude]="m.longitude"
[label]="m.name[0]">
<agm-info-window>
<strong>{{m.label}}</strong>
<strong>{{m.name}}</strong>
</agm-info-window>
</agm-marker>
</agm-map>

View file

@ -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';

View file

@ -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() );
}