11 Replies Latest reply on Mar 7, 2012 8:02 AM by Ronald Diemicke

    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);
      }
      
        • Re: Geolocation returns 0,0 position coordinates in RhoElements
          Robert Galvin

          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

          • Re: Geolocation returns 0,0 position coordinates in RhoElements
            Robert Galvin

            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.

              • Re: Geolocation returns 0,0 position coordinates in RhoElements

                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