-- Create a native map view
local myMap = native.newMapView( 20, 20, 280, 360 )
myMap.x = display.contentCenterX
local attempts = 0
local locationText = display.newText( "Location: ", 0, 400, native.systemFont, 16 )
locationText.anchorY = 0
locationText.x = display.contentCenterX
local function locationHandler( event )
local currentLocation = myMap:getUserLocation()
if ( currentLocation.errorCode or ( currentLocation.latitude == 0 and currentLocation.longitude == 0 ) ) then
locationText.text = currentLocation.errorMessage
attempts = attempts + 1
if ( attempts > 10 ) then
native.showAlert( "No GPS Signal", "Can't sync with GPS.", { "Okay" } )
else
timer.performWithDelay( 1000, locationHandler )
end
else
locationText.text = "Current location: " .. currentLocation.latitude .. "," .. currentLocation.longitude
myMap:setCenter( currentLocation.latitude, currentLocation.longitude )
--myMap:addMarker( currentLocation.latitude, currentLocation.longitude )
end
end
locationHandler()
settings =
{
android =
{
usesPermissions =
{
“android.permission.INTERNET”,
“android.permission.ACCESS_FINE_LOCATION”,
“android.permission.ACCESS_COARSE_LOCATION”,
},
},
}