Geolocation returns 0,0 position coordinates in RhoElements

Hey,

Is anybody else having an issue where the HTML 5 geolocation API returns 0 for the position.coords.latitude and position.coords.longitude?

When running the following code on chrome, it displays a value for latitude, longitude. When I run it in RhoElements, it gives me 0, 0. Any ideas on different things I could try? I am using an MC75 running Windows Mobile 6.5. Thanks!

function getGeoLocation()

{

    if(navigator.geolocation)

    {

       

        navigator.geolocation.getCurrentPosition(show_position);

    }

    else

    {

        alert('cannot get geolocation, no support');

    }

}

function show_position(position)

{

     alert(position.coords.latitude + ', ' + position.coords.longitude);

}

Robert Galvin
Nischal,I am still looking

Nischal,

I am still looking into the HTML5 geolocation feature, but in the meantime, attached is a sample file that uses the Com object to read the serial port. On Windows Mobile devices the GPS data (NMEA formatted) comes over the serial port. In the app it is set to COM6 (what is used by the ES400) you may have to change it for your device. But it is useful because you can see actual activity while the GPS fix is being obtained. Once it is obtained it will display the Lat/Long coordinates and then display a static google map (I think my conversion of coordinates is not 100% accurate but you get the idea). I think this may help you see better what is going on with GPS on your device. One downside I see with teh navigator.geolocation is that there are no provisions for feedback while a fix is being obtained and with non help from WLAN locationing this could take several seconds and possibly even a few minutes.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Lei Gong
Hi Rob,I am working on HTML5

Hi Rob,

I am working on HTML5 geolocation with RhoElements on MC65. I downloaded your sample code, your first sample (geolocation) works only when I started a GPS app (google maps) and activated the GPS and saw its activity before I started RhoElements. Your second sample (comm port) was kind of working, I did see data changed on comm port, but the result calculated was not correct.

Why the geolocation function in RhoElements needs another program to active the GPS? I'm thinking maybe it is related to user permission. Geolocation API Specification (http://dev.w3.org/geo/api/spec-source.html) requires that browser must get user's permission before share location info. When I implement geolocation in Android WebView, I have to override WebChromeClient.onGeolocationPermissionsShowPrompt to get user's permission. I am not sure what RhoElements does to implement this requirement.

By the way, I tried the new RhoElements version 1.0.2.3. It seems not compliant with geolocation. The geolocation function would break RhoElements, quit to OS without any notice.

Thanks,

Lei

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Robert Galvin
LeiThe RhoElements runtime

Lei

The RhoElements runtime application has permission to use GPS it is not required for the actual HTML application to handle this. The reason it is working better when another application like google maps is loaded first, is that the devices has received a GPS fix from the satellites. When you initiate the Geolocation code using HTML5 it is a "what is the position now (within timeout)" type of call. If the fix is received by the device before the timeout then the Geolocation method will be successful. I will try this again with the 1.0.2.3 release. What  device are you trying this with?

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Lei Gong
Rob,Thanks for the

Rob,

Thanks for the explanation. I am using a MC65 device. If I do not start google maps, what can I do to make sure the geolocation call get correct result? By increasing timeout time?

Lei

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Robert Galvin
Yes Lei – try increasing the

Yes Lei – try increasing the timeout. The serial example I sent you was to give you an idea of how ‘fast’ it takes for the information to start coming in from the GPS receiver and when it has a fix.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Robert Galvin
Nischal,Keep in mind that the

Nischal,

Keep in mind that the first time to get a GPS fix can take several minutes. The getCurrentPosition method you called above is basically "give me the location now". Which at the first time will not be anything. You need to include a timeout value. See below, I am using a 3 minute timeout on an ES400 (sitting outside with a clear view to the sky).

if (navigator.geolocation) {

                     alert("Geolocation is supported by this browser");

                      var timeoutVal = 360 * 1000 * 1000;

                      navigator.geolocation.getCurrentPosition(

                              displayPosition,

                              displayError,

                              { enableHighAccuracy: false, timeout: timeoutVal, maximumAge: 0 }

                      );

                    }

                    else {

                      alert("Geolocation is not supported by this browser");

                    }

Also note that if the device as assited GPS (like ES400 or MC65) the first time to fix will be quicker. Check the Start/Settings/Connections/GPS Assist for settings and when the last data was received from the AGPS server.

Also note that this version of RhoElements has a problem with the error callback function specified in getCurrentPosition, which is why you may not have seen an error like "timeout"Capture.PNG

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Nischal Vasant
Thank you, I didn't think of

Thank you, I didn't think of that. I will try it out with that parameter included. Does RhoElements support {enableHighAccuracy: true} ?

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Darryn Campbell
For what concerns the high

For what concerns the high accuracy mode, basically that looks like the only mode supported by Windows as it would always use the data coming from the GPS sub-system.

Low accuracy mode is based on ip or mac based databases, but the Windows API, and therefore RhoElements for Windows does not support low-accuracy mode.

On Android for instance, you can choose from which source you want to get the geolocation data, network only, gps only or both.

Hope that helps.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Ronald Diemicke
Rob,I'm using this sample

Rob,

I'm using this sample code on the ET1 and its returning an error code of 'Permission Denied' - How do I give Rho permission to get the location?

Thanks!

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Nischal Vasant
Hello Rob,Using the code you

Hello Rob,

Using the code you provided, and indoors/by window on an ES 400 & MC75 there was no reaction to pressing "get GPS". I downloaded the Google Maps app for Windows Mobile to see if it could ascertain the location. Sitting in the same position, it was able to get the location in Google Maps. I then fired up RhoElements, and it was able to give me coordinates. I rebooted the phone, opened up RhoElements first this time, and it reacted the same way it did prior to opening the Google Maps app. I was able to duplicate this on both phones. Is there anything I need to do in the phone OS before launching RhoElements? Perhaps I need to increase the timeout since I am indoors. I will try this tomorrow and report back.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Nischal Vasant
Hi guys,I am still having

Hi guys,

I am still having this issue with the device having trouble accessing the GPS location until AFTER the GPS has been accessed through google maps. I took it outside with a clear view of the sky, and the issue persisted. Having the same issue on multiple devices. Any idea what could be causing this?

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Log in to post comments