How to use the ionic-native.Geolocation.getCurrentPosition function in ionic-native

To help you get started, we’ve selected a few ionic-native examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github apppresser / ap3 / src / pages / google-map / google-map.ts View on Github external
doMap() {

  	if( plugin.google ) {

  		let mapDiv = document.getElementById("google-map");

  		// Do this when checkin button clicked
      Geolocation.getCurrentPosition().then((position) => {

          let latitude = position.coords.latitude;
          let longitude = position.coords.longitude;

          let pos = new plugin.google.maps.LatLng(latitude,longitude);

          // Initialize the map plugin
        	let map = plugin.google.maps.Map.getMap(mapDiv, {
        	      'camera': {
        	      'latLng': pos,
        	      'zoom': 10
        	    }
      	  });

  			  map.addMarker({
    		      'position': pos,
github doorty / Ionic-2-Uber / app / components / map / map.ts View on Github external
let locationObs = Observable.create(observable => {
      
      Geolocation.getCurrentPosition(options)
        .then(resp => {
          let lat = resp.coords.latitude;
          let lng = resp.coords.longitude;
          
          let location = new google.maps.LatLng(lat, lng);
          
          console.log('Geolocation: ' + location);
          
          observable.next(location);
          
          loading.dismiss();
        },
        (err) => {
          console.log('Geolocation err: ' + err);
          loading.dismiss();
        })
github microsoft / cordova-samples / weather-app-ionic2 / WeatherAppIonic2 / src / pages / home / home.ts View on Github external
getLocalWeather() {
        let locOptions = { 'maximumAge': 3000, 'timeout': 5000, 'enableHighAccuracy': true };
        Geolocation.getCurrentPosition(locOptions).then(pos => {
            //Store our location object for later use
            this.currentLoc = { 'lat': pos.coords.latitude, 'long': pos.coords.longitude };
            //and ask for the weather for the current location
            this.showCurrent();
        }).catch(e => {
            console.error('Unable to determine current location');
            if (e) {
                console.log('%s: %s', e.code, e.message);
                console.dir(e);
            }
        })
    }
github lhzbxx / Follow3 / mobile / app / providers / data-service.js View on Github external
token => {
                    Geolocation.getCurrentPosition().then((resp) => {
                        let url = this.BASE_URL + 'action';
                        let body = JSON.stringify({'access_token': token, 'action': action,
                            'target': target, 'lat': resp.coords.latitude, 'lng': resp.coords.longitude});
                        let headers = new Headers({'Content-Type': 'application/json'});
                        this.http.post(url, body, {headers: headers})
                            .map(res => res.json())
                            .subscribe(data => {
                                console.log(data.msg);
                                resolve();
                            }, error => {
                                reject();
                            });
                    });
                }
            );
github petronetto / ionic2-uber-clone / app / components / map / map.ts View on Github external
let locationObs = Observable.create(observable => {
      
      Geolocation.getCurrentPosition(options)
        .then(resp => {
          let lat = resp.coords.latitude;
          let lng = resp.coords.longitude;
          
          let location = new google.maps.LatLng(lat, lng);
          
          console.log('Geolocation: ' + location);
          
          observable.next(location);
          
          loading.dismiss();
        },
        (err) => {
          console.log('Geolocation err: ' + err);
          loading.dismiss();
        })
github Lacka90 / ionic-photo-maps / src / pages / photo / photo.ts View on Github external
return new Promise((resolve, reject) => {
      return Geolocation.getCurrentPosition().then((resp) => {
        this.locationLoading = false;
        resolve(resp.coords);
      }).catch((error) => {
        this.locationLoading = false;
        this.resetCoords();
      });
    });
  }
github zyra / ionic-native-playground / app / pages / main / main.ts View on Github external
this.platform.ready().then(() => {
            Geolocation.getCurrentPosition().then(
                res => this.updateOutput(res),
                err => this.updateOutput(err, true)
            );
        });
    }
github thomasgazzoni / ng2-platform / src / location / location.ionic.ts View on Github external
.create((observer: Observer) => {

                Geolocation.getCurrentPosition(options)
                    .then(pos => {
                        observer.next(pos.coords);
                        observer.complete();

                    }).catch(error => {
                        observer.error(error);
                        observer.complete();
                    });

            });
github PokemonGoers / Catch-em-all / ionic2 / src / components / map / map.component.ts View on Github external
showDirections(destination) {
    this.map.clearRoutes();

    Geolocation.getCurrentPosition().then(position => {
      let start = {
        latitude: position.coords.latitude,
        longitude: position.coords.longitude
      };
      this.map.navigate(start, destination);
    })
  }
}