Problema initializar latitud y longitud gps al momento de inicializar pantalla

He creado una aplicacion en Mit inventor 2 con una pantalla para que me muestre mi ubicacion actual el cual adjunte los controles map, sensordeubicacion y marker, todo esto probado en AI companation de mi celular que esta habilitado el GPS, el problema es cuando inicio la pantalla no me muestra la ubicacion actual, he asociado la propiedad locationsensor del control map con el control sensordeubicacion, he asociado la programacion Map.PanTo con los datos de latitud y longitud que esta dentro de las opciones del SensorDeUbicacion.CambioEnUbicacion, pareciera que cuando inicia la pantalla no esta leyendo el Gps. podrian ayudarme, gracias.

you will have to wait a few seconds until you get a satelite signal to get the current location

It would really help if you provided a screenshot of your relevant blocks, so we can see what you are trying to do, and where the problem may be.

To get an image of your blocks, right click in the Blocks Editor and select "Download Blocks as Image". You might want to use an image editor to crop etc. if required. Then post it here in the community.

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.

ubicacion_actual.aia (2.4 KB)

Este es el archivo de mi proyecto, algo simple pero no me funciona cuando ejecuto el AI Companation en mi celular que esta activado el GPS cuando ejecuto la aplicacion.

Probe tambien con los controles LocationSensor.Latitude y LocationSensorLongitude pero funcionaba cuando habilitaba y deshabilitaba el GPS del celular, no funcionaba cuando iniciaba la pantalla con el GPS del celular activado.

Adjunto mi proyecto, para que me ayuden y si puedan corregir porque no inicia la pantalla con la ubicacion actual. gracias

Your app project works OK for me.

Are you testing inside a building - if so, go outside to test.
The location sensor can take @ 30 seconds to get a fix to return your location

Also you need to change Label2 to longitude

Me parece confuso porque tengo aplicaciones como uber o waze instalado en mi celular y cuando los utilizo me muestran mi ubicación actual a comparación de la aplicación que adjunte en el mensaje no muestra mi ubicación y menos cambia los label.

cuando probando otra solución de cambiar los label y el map por los controles de LocationSensor.Latitude y LocationSensorLongitude igual no funcionaba cuando iniciaba la aplicación, solo funcionaba cuando cuando habilitaba y deshabilitaba el GPS del celular ahi recién actualizaba mi ubicación .

Espero la ayuda, gracia.

Did you try this?

Si amigo, ya lo probé y demoro mas de 1 minuto en actualizar la ubicación, donde vivo exactamente es un edificio y no se puede salir a la calle por la cuarentena del coronavirus, solo saque mi mano por la ventana pero igual demora mucho, el problema es por satelites?.

No habra otro manera para que la actualizacion de la ubicacion sea mas rapido, como es en las aplicaciones de uber o waze?, o esas aplicaciones trabajan con otra tipo de acceso al gps o redes.

Gracias por los consejos.

As you coded the LocationSensor, the TimerInterval is set to 60 seconds (60000 ms).
The LocationSensor in most phones cannot achieve a satellite fix (and a location changed event) faster than about 20 seconds. What can you do?

Perhaps these Blocks will help

LS .
The Blocks set the Location refresh to every 20 seconds and start it immediately (the first instance of a geocoordinate report is usually 30 seconds or more even then). Yes, the update can be a little bit faster. The 20000 ms will allow the gps to refresh every 20 seconds if that is possible. A limitation using the LocationSensor is that it is used with the original satellite constellations; uber and waze use technology that allow them to use all the possible satellite constellations that are possible with the gps hardware in your Android. Not all cell phones have gps receivers that are capable of refreshing fast even then.

Please read this Using the Location Sensor if you have not already read it. The tutorial will help you can understand how a gps receiver works; why there are issues sometimes and what can be done with the MIT LocationSensor / gps.

A GPS receiver in your Android can only work if it has a clear path to the sky. If you are in a metal framed building, your gps will probably not receive satellite fixes and signals unless you are near a window.

Regards,
Steve

Muchas gracias a todos por sus consejos y ayuda, logre solucionar el problema con un control clock para llamar al locationsensor.providername cuando se inicia la aplicacion.

Otra duda quetengo ahora es cuando mi aplicacion ya inicio y el celular esta activado el gps, la ubicacion actual en la aplicacion funciona bien, pero si el usuario desactiva el gps del celular la ubicación ya no se actualiza, como puedo hacer para que la aplicacion solicite volver activar el gps y posteriormente se actualize mi ubicacion actual?

Gracias a todos por el tiempo en la ayuda y consejos brindados.

Glad you got the LocationSensor working Miguel. If the user disables the gps in the phone, yes, the location will no longer be updated. The only thing that can be done is to manually turn on the Location Settings on the device. It is impossible to turn the GPS hardware on or off using code. It is a security feature of Android.

Depending on the version of Andorid, there is a screen in the device Settings that looks like this:

LocationSettings .
Your app can provide code to display the Location Setting options like this:

but the user MUST make the changes manually using the screen provided by the ActivityStarter.

Regards,
Steve

Gracias por la orientación, pero creo que me explique mal, no quiero habilitar o deshabilitar el gps automáticamente desde la aplicación por el tema de seguridad del dispositivo como bien lo explicastes, lo que quiero es que la aplicación detecte si el usuario ha deshabilitado el gps manualmente, y si ese fuera el caso envíe un mensaje al usuario para que vuelva habilitar el gps del celular, y que posteriormente la aplicación vuelva a testear la ubicación actual ya con el gps activado.

Gracias por el tiempo y paciencia en ayuadarme.

The first part is easy (send a notification to the user to manually enable the gps hardware if the GPS receiver is not enabled). Check the status of the LocationProvider and based on the Provider, do something. In this case, if the Provider is not gps, display the LOCATION Settings page from the Android system.

Place the Procedure call either in the Screen1.Initialize event handler or in a Button.

The second piece depends on whether the user decides to turn on the GPS receiver or not manually. Provide your own code to deal with what happens if the user does not turn the GPS on. Perhaps use a nagging Clock.

Regards,
Steve

2 Likes

Hola Miguel Lopez, podrías colocar un print de pantalla como configurastes el bloque con el control clock. Tengo ese mismo problema. cuando se inicializa la aplicación no toma la latitud y longitud. Muchas Gracias.

Hola,
Disculpa por la demora, ahi te envio el bloque.blocks (7)

2 Likes

Hola, ¿cómo configuras las propiedades de activity starter para activar gps? Saludos!

It is not possible to turn on the GPS receiver in your Android device using code. Google considers this a security leak so users have to turn on/off the GPS receiver in the device manually.

@MIGUEL_LOPEZ shows a way to check if the LocationSensor.Provider is set to gps and active. If it is not active, he uses the ActivityStarter to bring up a device Settings screen, similar to this one. The appearance of these controls vary among different Android operating system versions.

LocationSettings

Your app's USER must turn on Location or gps manually from his/her device using the Settings screen. You can also use this code ActivityStarterLocations
in an event handler.

No one, even using Android Studio can use code to turn on or off the Location settings. Google prohibits this.

Hola buenas noches. queria pedirles el favro estoy utilizando el webview haciedo la llamada de un mapa personalizado de google maps. al utilizar el mapa para ubicarme no me permite y me sale este error "google maps no pudo determinar tu ubicacion exacta"

location1

Please show your Blocks and how you use the WebViewer.

hola, retomo el tema, soy incapaz de hacer que algo de esto funcione, adjunto un programa sumamente sencillo que debe ir guardando las posiciones del gps, la verdad es que odio los móviles creo que solo sirven para producir cáncer y estas cosas solo hacen que se confirme más, no funciona algo tan simple y lo he probado en 3 moviles distintos, por favor a ver si me ayudais. Gracias
gps.aia (3.6 KB)