The four commands





all give wildly different results. None of them are correct (some even showing a different country). I assume that CloudEvaluate[Here] gives the location of the Wolfram Cloud server, but why is that different from the other CloudEvaluate commands?

I wish to create a FormPage in the Wolfram cloud where I can enter some data via my phone, including the phone's current location. How do I access the phone's GPS readings from a Wolfram cloud FormPage?

  • $\begingroup$ I thought that this one is a duplicate 116508 but the fact it is about APIFunction not a FormPage makes it different. $\endgroup$ – Kuba Jan 29 '19 at 13:51

This seems to work well, it will ask you to give permissions to access gps data and then our JS will initialize "yourPosition" field with coordinates taken from navigator (see: https://www.w3schools.com/html/html5_geolocation.asp)

        EmbeddedHTML @ StringJoin[
          "<script>function initYourPosition( position ) { document.getElementsByName('yourPosition')[0].value = ''+position.coords.latitude+','+position.coords.longitude;}</script>"
        , "<script>navigator.geolocation.getCurrentPosition(initYourPosition)</script>"
      , "yourPosition"->"GeoCoordinates"
      , GeoGraphics[{ GeoMarker[#], Inset[#2,#]}& @@@ {
          {FindGeoLocation[$RequesterAddress],"by requester address"},
      ] &
    , CreateUUID["temp/"]
    , Permissions -> "Public"

And the final result after allowing access and submitting:

enter image description here

I found a a Community.wolfram.com post that does even more: Exact GeoPosition from FormFunction but requires a little bigger html+js template.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.