mirror of
https://github.com/DerTyp7/local-analyzer-angular.git
synced 2025-11-02 22:43:46 +01:00
Added Search
This commit is contained in:
16
src/app/services/photon.service.spec.ts
Normal file
16
src/app/services/photon.service.spec.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
/* tslint:disable:no-unused-variable */
|
||||
|
||||
import { TestBed, async, inject } from '@angular/core/testing';
|
||||
import { PhotonService } from './photon.service';
|
||||
|
||||
describe('Service: Photon', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [PhotonService]
|
||||
});
|
||||
});
|
||||
|
||||
it('should ...', inject([PhotonService], (service: PhotonService) => {
|
||||
expect(service).toBeTruthy();
|
||||
}));
|
||||
});
|
||||
23
src/app/services/photon.service.ts
Normal file
23
src/app/services/photon.service.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { PhotonFeatureCollection } from '../interfaces/photon';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
/**
|
||||
* Communicates with Photon (https://photon.komoot.io/)
|
||||
*/
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class PhotonService{
|
||||
|
||||
constructor(private http: HttpClient) { }
|
||||
|
||||
/**
|
||||
* Sends a query request to Photon and gets response (https://photon.komoot.io/)
|
||||
*/
|
||||
sendQueryRequest(queryString: string): Observable<PhotonFeatureCollection> {
|
||||
return this.http.get<PhotonFeatureCollection>("https://photon.komoot.io/api/?q=" + queryString);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user