dpa99c / cordova-plugin-request-location-accuracy

Cordova/Phonegap plugin for Android and iOS to request enabling/changing of Location Services by triggering a native dialog
96 stars 62 forks source link

when turning on the gps it is not recognized by the google maps plugin #56

Closed jhonarodriguez closed 6 years ago

jhonarodriguez commented 6 years ago

I'm submitting a ... (check one with "x"):

Bug report

Current behavior:

Expected behavior:

Steps to reproduce:

Environment information

Runtime issue

Android build issue:

iOS build issue:

If using an [Ionic Native Typescript wrapper]() for this plugin:

Related code:

insert any relevant code here such as plugin API calls / input parameters

Console output

console output ``` // Paste any relevant JS/native console output here ```


**Other information:** # Feature request # Documentation issue Some time ago I was using this add-on, but after doing a test with the Google Maps Plugin, it turns out that it makes the request that it is necessary to turn on the GPS, and everything works well until there, the problem is that when I turn it on and go to use the google maps plugin function `map.getMyLocation().then().cath();` It does not execute anything, it does not enter either the .then () nor the .catch () function, but, after it is activated, if I deactivate the gps and turn it on MANUALLY !! there if you enter the google maps function. Perform another test with an application that I had a while ago, and the same problem occurs, or there are times when it takes the last position of the GPS where I was. I already asked the same question in the google maps plugin, I thought that they had something wrong there, but according to the creator, everything is working well, and he told me to communicate in the forum of this add-on. I hope someone can help me with this. I leave an example code. ``` import { LocationAccuracy } from '@ionic-native/location-accuracy'; import { GoogleMaps, GoogleMap, GoogleMapsEvent, GoogleMapOptions, Marker, MarkerLabel, MarkerClusterIcon, MarkerClusterOptions, MarkerCluster, CircleOptions, Circle } from '@ionic-native/google-maps'; @IonicPage() @Component({ selector: 'page-map', templateUrl: 'map.html', }) export class MapPage { map: GoogleMap; constructor( private navCtrl: NavController, public events: Events, private locationAccuracy: LocationAccuracy, public alertCtrl: AlertController, public plt: Platform ) { this.plt.ready().then(() => { this.readyPlatform(); }); } readyPlatform(){ this.locationAccuracy.canRequest().then((canRequest: boolean) => { // alert(canRequest); if(canRequest) { // the accuracy option will be ignored by iOS this.locationAccuracy.request(this.locationAccuracy.REQUEST_PRIORITY_HIGH_ACCURACY).then( () => { this.loadMap(); }, error => { let alert = this.alertCtrl.create({ title: 'Ups!', subTitle: 'Necesitamos que actives el gps para que funcione correctamente la aplicacion!', buttons: ['Aceptar'] }); alert.present(); } ); }else{ this.loadMap(); } }).catch((error) => { // alert('Error: ' + error); }); } loadMap(){ let mapOptions: GoogleMapOptions = { controls: { compass: false, myLocation: false, myLocationButton: false, mapToolbar: false }, preferences: { padding: { top: 70, left: 30, right: 30, bottom: 40 }, building: true } }; this.map = GoogleMaps.create('map_canvas', mapOptions); // Wait the MAP_READY before using any methods. this.map.one(GoogleMapsEvent.MAP_READY) .then(() => { this.getPosition(); }) .catch(error =>{ console.log(error); }); } getPosition(): void{ let optionsLocation = { enableHighAccuracy: true} this.map.getMyLocation(optionsLocation).then((resp) => { console.log(resp); }).catch((error) => { console.log('Error getting location', error); }); } } ``` The question is that when it reaches the function getPosition () does not work, it does not send error or anything. I am currently using the https://github.com/apache/cordova-plugin-geolocation plug-in but it takes a long time to get the location, so I would prefer to use the Google Maps plug-in.
dpa99c commented 6 years ago

On the Android platform, this plugin provides a wrapper to call the native Google Play Services Location API which is what actually displays the native dialog and changes the location mode if the user agrees. Therefore any issue you're having with another plugin after changing location mode is caused by the native Play Services Location API, not this plugin directly which only invokes the native API.

Regardless of this, I understand from your description that this plugin works find with cordova-plugin-geolocation but not the Google Maps plugin. Therefore I suggest you open the issue against the Google Maps plugin, not this one.