Reputation: 3451
hi im trying but i can not, so i want get country name with function in google maps api
import {Injectable} from '@angular/core';
import {Observable} from "rxjs/Observable";
import 'rxjs/add/operator/map';
findMapData(results): string {
return results.results[0].address_components.map(res => {
return res.types[0] === 'country' ? res.short_name : "";
});
}
this.findMapData(mapData);
I need just country name ?
Upvotes: 0
Views: 199
Reputation: 222700
Use find instead
findMapData(results): string {
return results.results[0].address_components.find(res => res.types[0] === country).short_name;
}
then
this.findMapData(mapData);
Upvotes: 1