This repository has been archived on 2023-08-16. You can view files and clone it, but cannot push or open issues or pull requests.
FoodLoop-Web/src/app/dashboard/map.component.ts

60 lines
1.4 KiB
TypeScript
Raw Normal View History

2017-09-27 12:54:10 +00:00
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
2017-09-26 16:31:40 +00:00
import { Http, Response } from '@angular/http';
import { ApiService } from '../providers/api-service';
import { AgmCoreModule } from '@agm/core';
import 'rxjs/add/operator/map';
@Component({
templateUrl: 'map.component.html',
})
export class MapComponent implements OnInit {
lat: number = 54.0466;
2017-09-26 16:51:14 +00:00
lng: number = -2.8007;
2017-09-27 11:02:46 +00:00
zoom: number = 12;
2017-09-26 16:31:40 +00:00
2017-09-27 12:54:10 +00:00
dataReceived: string = 'yes';
map: any;
2017-09-26 16:31:40 +00:00
constructor(
private http: Http,
private api: ApiService,
) { }
2017-09-27 12:54:10 +00:00
ngOnInit(): void { }
public onMapReady(map: any) {
this.map = map;
}
2017-09-26 16:31:40 +00:00
2017-09-27 12:54:10 +00:00
public viewBoundsChanged() {
console.log("finding bounds");
const resp = this.map.getBounds();
console.log("found bounds");
console.log(resp.getNorthEast().lat());
console.log(resp.getNorthEast().lng());
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()
};
this.api.getMapData(mapData).subscribe(
result => {
this.dataReceived = 'yes';
},
error => {
// this.dataReceived = 'no';
console.log('Retrieval Error');
console.log( error._body );
}
);
2017-09-26 16:31:40 +00:00
}
2017-09-27 12:54:10 +00:00
2017-09-26 16:31:40 +00:00
}