009topersky commented on issue #255: URL: https://github.com/apache/cordova-plugin-geolocation/issues/255#issuecomment-1338506813
Good day everyone! our team are using ionic 4 in our application, To solve the issue we use the https://github.com/mapsplugin/cordova-plugin-googlemaps. First, you have to follow the instruction on the documentation and get the API KEY from Google. setup your project here: https://console.cloud.google.com/apis/credentials?authuser=2 Second, in config.xml add this line also you can read it on the documentation of the plugin: `<preference name="GOOGLE_MAPS_ANDROID_API_KEY" value="YOUR_API_KEY_FROM_GOOGLE_CONSOLE" />` Third, under `app.module.ts` include the `LocationService` ``` @NgModule({ declarations: [AppComponent], entryComponents: [], imports: [ .... LocationService .... ] }); ``` Fourth, import the `LocationService` and create a function to get the geolocaion. ``` import { LocationService, MyLocation, MyLocationOptions } from '@ionic-native/google-maps'; .... async getGoogleCurrentLocationAsync() { const options: MyLocationOptions = { enableHighAccuracy: true }; return await LocationService.getMyLocation().then((myLocation) => { if (myLocation) { const coordinate: Coordinates = { latitude: myLocation.latLng.lat, longitude: myLocation.latLng.lng, accuracy: myLocation.accuracy, altitude: myLocation.altitude, speed: myLocation.speed, altitudeAccuracy: null, heading: null, }; return coordinate; } return false; }, (_error) => false) .catch((_e) => false) } ``` That's it! I hope this answer will help! Thanks -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
