-1
Hi, I have to search Longitude and Latitude, by Google API, with Angular..
I’m using this code to perform the requisition:
constructor(private http: Http, private vwServicePagination: VwServicePagination){}
    obtendoGeolocalizacao() {  
        return this.http.get('https://maps.googleapis.com/maps/api/geocode/json?address=09771220')
            .map(response => response.json());
    }And here at Oninit I’m calling this method created above... This way:
ngOnInit(){
        const teste = this.vwServiceApi.obtendoGeolocalizacao();
        
        console.log(this.teste);
    }However, the returned object has nothing to do with the json that is returned by the API! How do I get the JSON object returned by the API?
vc have to use subscribe, this.vwServiceApi.getting locationGocation(). subscribe(reply=> console.log(reply))
– Eduardo Vargas
Good, If you want to paste in your answer... ngOnInit(), # this.vwServiceApi.getting the location(). subscribe(res => {this.apiGoogle = res.json(); const lat = this.apiGoogle.Results[0].geometry.Location.lat; const lng = this.apiGoogle.Results[0].geometry.Location.lng; }); this.dealerships = this.vwServiceApi.dealerships(); }
– Guilherme Nunes