Hello I'm trying to get the latitude and longitug in angular and be saved in firebase give me this error
My code is:
import {Component, OnInit} from '@ angular / core'; import {PlacesService} from '../services/ places.service';
@Component ({ selector: 'app-create', templateUrl: './crear.component.html', styleUrls: ['./crear.component.css'] }) export class CrearComponent { place: any = {}; constructor (private placesService: PlacesService) { } saveLoad () {
var direccion = this.lugar.calle+','+ this.lugar.ciudad+','+this.lugar.pais;
this.lugaresService.obtenerGeoData(direccion)
.subscribe((result) => {
this.lugar.lat = result[0].geometry.location.lat;
this.lugar.lng = result[0].geometry.location.lng;
this.lugar.id = Date.now();
this.lugaresService.guardarLugar(this.lugar);
alert('Indicio guardado con exito');
this.lugar = {};
});
var direccion = this.lugar.calle+','+ this.lugar.ciudad+','+this.lugar.pais;
this.lugaresService.obtenerGeoData(direccion)
.subscribe((result) =>{
this.lugar.lat = this.lugar.lat = result[0].geometry.location.lat;;
this.lugar.lng = this.lugar.lng = result[0].geometry.location.lng;
this.lugar.id = Date.now();
this.lugaresService.guardarLugar(this.lugar);
alert('Indicio guardado con exito');
this.lugar = {};
});
}
}
/ *
and so I call the service
public obtenerGeoData(direccion) {
return this.http.get('http://maps.google.com/maps/api/geocode/json?address=' + direccion + '&key=<tu api key>' );
}