Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

289
Views
Error del complemento de geolocalización iónica: "No hay proveedor para geolocalización"

Estoy tratando de usar la geolocalización en mi proyecto ionic2 hello world, y agrego el complemento iónico "Geolocalización" siguiendo las instrucciones en el sitio oficial .

He ejecutado estos dos comandos:

 $ ionic plugin add cordova-plugin-geolocation $ npm install --save @ionic-native/geolocation

Y esta es mi casa.ts:

 import { Component } from '@angular/core'; import {Geolocation} from '@ionic-native/geolocation' import { NavController } from 'ionic-angular'; @Component({ selector: 'page-home', templateUrl: 'home.html' }) export class HomePage { map:any=null; geoInfo:any={ resp:'', data:'' }; constructor( public navCtrl: NavController, private geolocation: Geolocation ) { } test(){ this.geolocation.getCurrentPosition().then((resp) => { this.geoInfo.resp=JSON.stringify(resp); // resp.coords.latitude // resp.coords.longitude }).catch((error) => { console.log('Error getting location', error); this.geoInfo.resp='Error getting location'; }); let watch = this.geolocation.watchPosition(); watch.subscribe((data) => { this.geoInfo.data=JSON.stringify(data); // data can be a set of coordinates, or an error (if an error occurred). // data.coords.latitude // data.coords.longitude }); } }

Sin embargo, recibí el siguiente error en la consola de mi Chrome:

 EXCEPTION: Error in ./TabsPage class TabsPage - inline template:0:0 caused by: No provider for Geolocation! error_handler.js:56ORIGINAL EXCEPTION: No provider for Geolocation!

captura de pantalla

Al principio pensé que era porque estaba depurando en el navegador, pero luego recibí el mismo error en mi teléfono Android.

Entonces, ¿qué significa "Sin proveedor de geolocalización" y cómo debo usar la geolocalización en mi proyecto ionic2?

¡Muchas gracias!

about 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Debe agregar el proveedor al NgModule, es decir, module.ts en proveedores,

 providers: [ Geolocation ]
about 4 years ago · Santiago Trujillo Report

0

Debe importar la clase Geolocalización y agregarla a su lista de proveedores en el archivo app.module.ts

 import { Geolocation } from '@ionic-native/geolocation'; providers: [ Geolocation ]
about 4 years ago · Santiago Trujillo Report

0

Para Ionic 4 , agrega a app.module.ts top:

 import { Geolocation } from '@ionic-native/geolocation/ngx';

Y en la parte inferior, dentro de la matriz Providers , agregue Geolocation :

 providers: [ Geolocation, ... ]
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!