Not understanding output from Geolocation


#1

Hi

I am struggling with Geolocation, taking the example from the Ionic 2 docs (on watching Geolocation).

var subscription = Geolocation.watchPosition()
                          .filter((p) => p.code === undefined) //Filter Out Errors
                          .subscribe(position => { console.log(position.coords.longitude + ' ' + position.coords.latitude);});

First of all, the test on coordinates p.code === undefined resolves to true while a JSON.stringify(p) assigned to a string variable for presentation on the page shows {}.

And while deepdiving into it, doing a console.log(position) shows the Geolocation object filled with content, but a console.log(JSON.stringify(position)) shows {} . But if I JSON.stringify(position.coords.latitude) I get an attitude number.

I can continue with my project, but don’t understand what is happening. Any suggestions?

Tom