- /** Fetching the location with name,latitude,longitude @public */
- public fetchLocationLatLong(value: string): void {
- this.isLocationLoadingResults = true;
- const newVIMLocation: VIMLOCATIONDATA[] = [];
- const locationTrack: string = environment.MAPLATLONGAPI_URL;
- const locationAPIURL: string = locationTrack.replace('{value}', value);
- this.restService.getResource(locationAPIURL).subscribe((result: VIMLOCATION) => {
- result.features.forEach((getFeturesResult: FEATURES) => {
- if ('extent' in getFeturesResult.properties) {
- getFeturesResult.properties.extent.forEach((extentResult: number, index: number) => {
- if (index === 0) {
- this.setLong = extentResult;
- }
- if (index === 1) {
- this.setLat = extentResult;
- }
- });
- } else {
- getFeturesResult.geometry.coordinates.forEach((coordinateResult: number, index: number) => {
- if (index === 0) {
- this.setLong = coordinateResult;
- }
- if (index === 1) {
- this.setLat = coordinateResult;
- }
- });
- }
- newVIMLocation.push({
- label: getFeturesResult.properties.name + ',' + getFeturesResult.properties.state + ', ' + getFeturesResult.properties.country,
- value: getFeturesResult.properties.name + ',' + this.setLong + ',' + this.setLat
- });
- });
- this.getVIMLocation = newVIMLocation;
- this.isLocationLoadingResults = false;
- }, (error: ERRORDATA) => {
- this.restService.handleError(error, 'get');
- this.isLocationLoadingResults = false;
- });
- }
-