I cannot access position data from getUserLocation()

I’m playing with newMapView a bit, but haven’t come far unfortunately. In the simple code snipped below, I have tried to once a second get the position of the device:

myMap = native.newMapView(display.contentWidth/2, display.contentHeight/2-150, display.contentWidth, display.contentHeight-300) myMap.mapType = "standard" -- other mapType options are "satellite" or "hybrid" local statusText = display.newText("Init...", display.contentWidth/2, display.contentHeight-200) local function callMap()   -- Fetch the user's current location   local currentLocation = myMap:getUserLocation()   if (currentLocation) then --        statusText.text = "Pos: " .. currentLocation.latitude .. ", " .. currentLocation.longitude         statusText.text = "Pos known"     else         statusText.text = "Pos not known (yet)"     end end timer.performWithDelay( 1000, callMap, 0)      -- get current location each second 

The code runs just fine as it is now “Pos known” is written in the status field. But if I try to actually write the position data by using the line of code that is commented out, nothing is written (and the app seems to become unstable).

Is this not the right way to access the position data from currentLocation?

To answer myself: It seems like this line is the culprit:

if (currentLocation) then

It should have been

if (currentLocation.errorCode) then

And with reversing th lines below, of course. Somthing like this:

  if (currentLocation.errorCode) then         statusText.text = "Pos not known (yet)"     else         statusText.text = "Pos known"     end

To answer myself: It seems like this line is the culprit:

if (currentLocation) then

It should have been

if (currentLocation.errorCode) then

And with reversing th lines below, of course. Somthing like this:

  if (currentLocation.errorCode) then         statusText.text = "Pos not known (yet)"     else         statusText.text = "Pos known"     end