Quantcast
Channel: Ionic Forum - Latest posts
Viewing all articles
Browse latest Browse all 228595

Ionic 2 Beta / Geolocation plugin not working

$
0
0

I'm following the steps at http://ionicframework.com/docs/v2/platform/geolocation/ to call the geolocation plugin:

import {Geolocation} from 'ionic/ionic';

export class Locations {

    constructor() {
        console.log('entering constructor');
        let options = {timeout: 10000, enableHighAccuracy: true};
        Geolocation.getCurrentPosition(options).then((position) => {
            let lat  = position.coords.latitude
            let long = position.coords.longitude
        }, (err) => {
        // error
        });

        //switching to Geolocation.getCurrentPosition to navigator.geolocation.getCurrentPosition
        //causes an error saying the 1st argument is not a function
    }
}

However, the code above results in an error that getCurrentPosition of undefined can't be retrieved. Is the documentation for Geolocation out of date or am I doing something wrong?


Viewing all articles
Browse latest Browse all 228595

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>