Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. constructor(
  2. private geolocation: Geolocation,
  3. private nativegeocoder: NativeGeocoder
  4. ) {
  5. this.getGeoLocation();
  6. }
  7.  
  8. getGeoLocation() {
  9. const options: NativeGeocoderOptions = {
  10. useLocale: true,
  11. maxResults: 5
  12. };
  13. this.geolocation.getCurrentPosition().then((resp) => {
  14. console.log(resp);
  15. this.nativegeocoder.reverseGeocode(resp.coords.latitude, resp.coords.longitude, options)
  16. .then((result: NativeGeocoderResult[]) => {
  17. console.log(JSON.stringify(result[0]));
  18. }).catch((error) => console.log(error));
  19. }).catch((error) => {
  20. console.log(error);
  21. });
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement