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?