5 Replies Latest reply on Jun 9, 2014 4:18 AM by Kutir Mobility

    Geolocation setup

    Peter Mannix

      Hi,

       

      Been reading through documentation on setting up Geolocation. So far I have been unable to make this work.

      I have added:

      capabilities:

        - gps

       

      I get the following error when running:

      APP     |      const_missing: Geolocation

      APP     |      Application activate failed: #<NameError: uninitialized constant Rho::Geolocation>;Trace:

       

      Does anyone have info on why this is occurring and what can be done to fix it?

        • Re: Geolocation setup
          Jon Tara

          The documentation is all wrong.

           

          It's GeoLocation, not Geolocation! (Note capitalization.)

           

          (Maybe it's different in Javascript. I use it in Ruby.)

           

          Oh, maybe they changed in in 4.x? (While still keeping the old capitalization for compatibility?) 2.x documents it as GeoLocation.

           

          My code still works in 4.x.

           

          What version of Rhodes are you using? Make sure you use the correct documentation.

          1 of 1 people found this helpful
            • Re: Geolocation setup
              Peter Mannix

              Hi,

              Thanks for that, didnt notice the capital.

              That works in Ruby but still not in JS.

              Get undefined for GeoLocation (and Geolocation).

              I ran console.log(Rho) which returns a list of items similar to those listed here RhoMobile API Summary

              but doesnt include Geo[l\L]ocation

               

              As far as Rho version, its what comes with RMS 4.1.0

               

              While I could hack around this, does anyone know how to get gps in JS working?

                • Re: Geolocation setup
                  BHAKTA RANJAN SATAPATHY

                  There is no GeoLocation api available for JavaScript.

                  You can do ajax call to your controller to get the current latitude and longitude.

                  And in geolocation callback you can use Rho::WebView.executeJavascript to update your DOM.


                  There is one more way available in rhodes i.e by using HTML tag. Kindly go through the docs available at http://docs.rhomobile.com/en/4.0.0/guide/geolocation

                  #Asynchronous Ajax calls

                   

                   

                  Thanks

                  • Re: Re: Geolocation setup
                    Kutir Mobility

                    Peter,

                    A limited version of the GeoLocation API is available in Javascript .

                    If you link the rho_javascript_api.js file as follows:


                    - in build.yml, include:

                    capabilities:

                      - gps

                    extensions:

                      - rho-javascript

                      - json

                     

                    - in your layout.html file, include the following files: (order is important, these files must be included exactly in the order shown)

                     

                            <script src="js/rho_javascript_api.js"></script>

                            <script src="js/rho_common_api_noconflict.js"></script>

                            <script src="api/rhoapi-modules.js"></script>

                     

                    This provides you with a Rho.GeoLocation (note capital L) object, with the following methods:

                     

                        latitude

                        longitude

                        is_known_position

                        turnoff

                        set_notification

                        haversine_distance

                    Those instructions are for 4.0, I have not tested 4.1 yet.


                    Visnupriya R

                    Kutir Mobility