Hi,
I’m trying to use gps coordenates from where I’m but it’s giving me the wrong position.
Never had problems before in previews works with same code.
The only difference is i’m updating corona versions.
Corona is working on GPS code? (Runtime:addEventListener( “location”, locationHandler ))
my code is very simple:
function gps.new(paramsIn) local mainGroup={} local params=paramsIn or {} local func=params.func or nil local locationHandler = function( event ) if ( event.errorCode ) then native.showAlert( "GPS Location Error", event.errorMessage, {"OK"} ) print( "Location error: " .. tostring( event.errorMessage ) ) else if func then func(event) end end end if system.hasEventSource( "location" ) then system.setLocationThreshold( 5 ) system.setLocationAccuracy( 10 ) Runtime:addEventListener( "location", locationHandler ) end mainGroup.locationHandler=locationHandler return mainGroup end function gps.updateCoordenates(objIn) local obj=objIn local locationHandler=obj.locationHandler if locationHandler then Runtime:removeEventListener( "location", locationHandler ) Runtime:addEventListener( "location", locationHandler ) end end
to call this functions:
local lat=0 local lng=0 local function func\_lat\_long(paramsIn) local params=paramsIn lat=params.latitude or 0 lng=params.longitude or 0 print ("\_\_\_") print (lat, lng) print ("\_\_\_") end local locationHandlerFunction=gps.new({func=func\_lat\_long}) ... gps.updateCoordenates(locationHandlerFunction)
it gives me coordenates but not from where i’m. About a 1km away from here. if i open a google map webpage in same app, google will point where i’m correctly. Corona is not.
Regards,
Carlos.
