{{direccion}}
{{lat}}
diff --git a/src/app/home/home.page.html b/src/app/home/home.page.html index a1e9ae0..8f22df7 100644 --- a/src/app/home/home.page.html +++ b/src/app/home/home.page.html @@ -7,7 +7,39 @@{{direccion}}
{{lat}}
diff --git a/src/app/home/home.page.ts b/src/app/home/home.page.ts index aa35261..7ecf766 100644 --- a/src/app/home/home.page.ts +++ b/src/app/home/home.page.ts @@ -11,7 +11,29 @@ public direccion: string = ""; public lat = null; public lng = null; - + public groupname: string = "Cliente"; + public groups: boolean = false; + public terms: boolean = true; + /// + /// Se agrego arreglo con abreviaturas de departamento y nombres de ciudad + public data = { + direccion:"", + ciudad:"", + numero:"", + casa:"", + departamento:[{ + id:0, + nombre:"Medellin", + abreviatura:"ANTQ" + }, + { + id:1, + nombre:"Pamplona", + abreviatura:"NS" + } + ], + is_superuser: true + }; constructor(private googleMap: GooglemapService) {} ngOnInit(){ @@ -19,12 +41,15 @@ } dir(){ - this.googleMap.loadMap().then((data:any) => { - console.log("direccion", data); + this.googleMap.loadMap(this.data).then((data:any) => { + this.direccion = data.dir; this.lat = data.lat; this.lng = data.lng; }) } + send(){ + + } } diff --git a/src/app/home/home.page.html b/src/app/home/home.page.html index a1e9ae0..8f22df7 100644 --- a/src/app/home/home.page.html +++ b/src/app/home/home.page.html @@ -7,7 +7,39 @@{{direccion}}
{{lat}}
diff --git a/src/app/home/home.page.ts b/src/app/home/home.page.ts index aa35261..7ecf766 100644 --- a/src/app/home/home.page.ts +++ b/src/app/home/home.page.ts @@ -11,7 +11,29 @@ public direccion: string = ""; public lat = null; public lng = null; - + public groupname: string = "Cliente"; + public groups: boolean = false; + public terms: boolean = true; + /// + /// Se agrego arreglo con abreviaturas de departamento y nombres de ciudad + public data = { + direccion:"", + ciudad:"", + numero:"", + casa:"", + departamento:[{ + id:0, + nombre:"Medellin", + abreviatura:"ANTQ" + }, + { + id:1, + nombre:"Pamplona", + abreviatura:"NS" + } + ], + is_superuser: true + }; constructor(private googleMap: GooglemapService) {} ngOnInit(){ @@ -19,12 +41,15 @@ } dir(){ - this.googleMap.loadMap().then((data:any) => { - console.log("direccion", data); + this.googleMap.loadMap(this.data).then((data:any) => { + this.direccion = data.dir; this.lat = data.lat; this.lng = data.lng; }) } + send(){ + + } } diff --git a/src/app/services/googlemap.service.ts b/src/app/services/googlemap.service.ts index a87ef53..24add89 100644 --- a/src/app/services/googlemap.service.ts +++ b/src/app/services/googlemap.service.ts @@ -19,12 +19,13 @@ - async loadMap() { + async loadMap(direccion:any) { + console.log("serviceeeeee") const myLatLng: any = await this.getLocation(); this.data.latitud = myLatLng.lat; this.data.longitud = myLatLng.lng; - let data = await this.direccion(); + let data = await this.direccion(direccion); return data; } @@ -39,31 +40,48 @@ private async verificationLocation() {} /// Permite obtener la direccion y el barrio a partir de las coordenadas - private direccion() { + private direccion(direccion:any) { + console.log(direccion) return new Promise((resolve, reject) => { const lat = this.data.latitud; const long = this.data.longitud; + + let idCiudad = direccion.ciudad; + let ciudad ="" + let abrebiatura = ""; + let numero = direccion.numero; + let casa = direccion.casa; + if(idCiudad!=""){ + ciudad = direccion.departamento[idCiudad].nombre + abrebiatura = direccion.departamento[idCiudad].abreviatura + console.log(ciudad+" "+abrebiatura) + } + this.http .get<{ status: string; results: any[] }>( - `https://maps.googleapis.com/maps/api/geocode/json?latlng=${lat},${long}&key=${this.TU_LLAVE}`, - { responseType: "json" } + `https://maps.googleapis.com/maps/api/geocode/json?address=CL+`+numero+`+`+casa+``+ciudad+`, + +`+abrebiatura+`,+CO&key=${this.TU_LLAVE}`, + { responseType: 'json' } ) .subscribe((e) => { - if (e.status === "OK") { - //this.data.direccion = e.results[0].formatted_address; - - //this.data.barrio = e.results[0].address_components[2].long_name; + if (e.status === 'OK') { + // console.log(e.results[0].geometry.location) + // this.data.direccion = e.results[0].formatted_address; + //lat = e.results[0].geometry.location.lat + const lat = e.results[0].geometry.location.lat + const long = e.results[0].geometry.location.lng + // this.data.barrio = e.results[0].address_components[2].long_name; resolve({ dir: e.results[0].formatted_address, - lat: lat, + lat, lng: long, }); } else { resolve({ - dir: "", + dir: '', lat: null, lng: null, - }) + }); } }); });