gps giving me wrong coordenates. (Runtime:addEventListener( "location", locationHandler ))

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.

forget it. it started to work fine when i moved around

i guess i had my phone uncalibrated. still it is strange when removing and creating the listener corona gave me always the same wrong coordenates and in google maps, i had a perfect location (outside corona).

after i moved around…corona started to give me correct coordenates.

well, the problem still remains. When I start the app the coordinates that are shown are from the last position app where app was opened and not from current position.

If the person starts to move it will eventually correct the position but in my case, I need the correct position before I move. I create a route for the person based on the current position when he presses a button. I remove the event and create it to refresh the gps position but nothing happens…it will return previews values and not current position, it will show an incorrect route because of that.

I’m testing on Android 8.0 device with corona last build (2018.3265). In Ipad it works like it should.

We haven’t made changes to location services in a long time.  Now I notice that you’re testing on Android 8. It could be an issue localized to that version of Android. 

Rob

this is a know issue? today update says about removing and adding event not doing nothing…it looks like location events are even worst…they report last time gps position and not current position…i really don’t know what to do. never had a single problem in this regard in 2 years…

i will try to test with lower devices on monday, and make more tests on IOS. i’ve 3 apps going on, all depending on gps position. Don’t know what to say to the costumers if this is not resolved.

i will try also creating a hidden map and get position from map using “myMap:getUserLocation()”, if this last resort fails, i don’t know what to do more. i tried 100x different ways…all with the same result.

The worst i can’t test on simulator…so lots of time making builds…

Have you tried doing live builds for device testing? It’s a really cool feature. Save the code in your editor, watch the app update on your device.

Rob

Also we will likely need a bug report filed for it as well with a demo project so we can build and test it without having to guess at what you’re doing.

Thanks

Rob

Rob i tried live builds when corona introduced them…but crashed Corona all over the place. i will try again if its more stable.

Regards of the bug report, i still don’t know if is Corona fault or my device fault. i need to test on more devices, tomorrow i will put some code to anyone who can test it. its a simple get coordinates app…if you move around and refresh the app it should give you new coordinates if it doesn’t it means it didnt refresh the coodinates so Corona is to blame.

Well, I manage to test on another Android 8 device, and the problem is exactly the same as mine.

On Ipad mini 4 3G it works like a charm.

I don’t have any none android 8 in my hands to test it so I need your help guys to test it.

You just need to run the app. it should give you the current position. if you press the button, it will show a route to a place (you can change that place in the code (latDest, lngDest) …move 50meters or more…press the button again, see it the gps changes and the route is updated. if it does it’s refreshing gps position right…if its not…corona have a bug that needs to be corrected.

Hope anyone can test this. I’m on a final phase of a app and i thought this was an easy part because i already did it on previews apps, now this is giving me problems :confused:

Regards,

Carlos Costa.

P.S: I will make a bug report anyway since this is a very urgent matter that needs to be looked at. *edit* already sent bug report.  {13959857} 

P.S: wheres my file that i uploaded???

forget it. it started to work fine when i moved around

i guess i had my phone uncalibrated. still it is strange when removing and creating the listener corona gave me always the same wrong coordenates and in google maps, i had a perfect location (outside corona).

after i moved around…corona started to give me correct coordenates.

well, the problem still remains. When I start the app the coordinates that are shown are from the last position app where app was opened and not from current position.

If the person starts to move it will eventually correct the position but in my case, I need the correct position before I move. I create a route for the person based on the current position when he presses a button. I remove the event and create it to refresh the gps position but nothing happens…it will return previews values and not current position, it will show an incorrect route because of that.

I’m testing on Android 8.0 device with corona last build (2018.3265). In Ipad it works like it should.

We haven’t made changes to location services in a long time.  Now I notice that you’re testing on Android 8. It could be an issue localized to that version of Android. 

Rob

this is a know issue? today update says about removing and adding event not doing nothing…it looks like location events are even worst…they report last time gps position and not current position…i really don’t know what to do. never had a single problem in this regard in 2 years…

i will try to test with lower devices on monday, and make more tests on IOS. i’ve 3 apps going on, all depending on gps position. Don’t know what to say to the costumers if this is not resolved.

i will try also creating a hidden map and get position from map using “myMap:getUserLocation()”, if this last resort fails, i don’t know what to do more. i tried 100x different ways…all with the same result.

The worst i can’t test on simulator…so lots of time making builds…

Have you tried doing live builds for device testing? It’s a really cool feature. Save the code in your editor, watch the app update on your device.

Rob

Also we will likely need a bug report filed for it as well with a demo project so we can build and test it without having to guess at what you’re doing.

Thanks

Rob

Rob i tried live builds when corona introduced them…but crashed Corona all over the place. i will try again if its more stable.

Regards of the bug report, i still don’t know if is Corona fault or my device fault. i need to test on more devices, tomorrow i will put some code to anyone who can test it. its a simple get coordinates app…if you move around and refresh the app it should give you new coordinates if it doesn’t it means it didnt refresh the coodinates so Corona is to blame.

Well, I manage to test on another Android 8 device, and the problem is exactly the same as mine.

On Ipad mini 4 3G it works like a charm.

I don’t have any none android 8 in my hands to test it so I need your help guys to test it.

You just need to run the app. it should give you the current position. if you press the button, it will show a route to a place (you can change that place in the code (latDest, lngDest) …move 50meters or more…press the button again, see it the gps changes and the route is updated. if it does it’s refreshing gps position right…if its not…corona have a bug that needs to be corrected.

Hope anyone can test this. I’m on a final phase of a app and i thought this was an easy part because i already did it on previews apps, now this is giving me problems :confused:

Regards,

Carlos Costa.

P.S: I will make a bug report anyway since this is a very urgent matter that needs to be looked at. *edit* already sent bug report.  {13959857} 

P.S: wheres my file that i uploaded???