Forum Discussion

PaulVorster1's avatar
PaulVorster1
Qrew Cadet
6 years ago

Geo Location Button Desktop vs Mobile (Creating a button that captures the current Geo Location and updating a date field on Mobile.)

Goodday Everyone, I hope someone can assist out there...we have created a GEO Locate button, whcih captures the Current User Location and also update a date field.  When we test the button on desktop, it works perfectly, but it doesnt want to work on mobile.  Can anyone assist in having a look at our code?

Current Button Code:
If([Start_Latitude] = null and [Start_Longitude] = null, 
"javascript:" &
"var QBU_recid="& [Record ID#] & ";" &
"void(jQuery.getScript('" & URLRoot() & "db/bniyztgvg?act=dbpage&pagename=insertGeoLocationStart.js'));", 
"javascript: alert('A location for this drop has already been captured.');")
&
If([Start_Latitude] <> null and [Start_Longitude] <> null, "javascript:DoSaveAdd()")


Current Javascript Page:
jQuery(document).ready(function getLocation()
  {
  if (navigator.geolocation)
    {
    navigator.geolocation.getCurrentPosition(showPosition);
    }
  
var test = $.ajax({url: url,async:false,success: pushResult}).responseText;
   return false;
});


function showPosition(position){

      //alert("insertGeo Running!");
      var dateNow = new Date();
      var cdate = ('0' + dateNow.getDate()).slice(-2) + '-' +  ('0' + (dateNow.getMonth()+1)).slice(-2) + '-' + dateNow.getFullYear() + ' ' + dateNow.getHours() + ':' +(dateNow.getMinutes() < 10 ? "0" : "" ) + dateNow.getMinutes();

      //edit record
      var editURL = "";
      editURL = "bniyztgvg";
         editURL += "?act=API_EditRecord&key=" + QBU_recid;
_fid_180.value = position.coords.latitude;
      _fid_181.value = position.coords.longitude;
_fid_77.value = cdate;
addURL += "&apptoken=n8wdqec5bzncectj7v7edp8ad9x";
  
        

      $.ajax({url: editURL,async:false});
      location.reload(true);
 }


4 Replies

  • Hi Paul,
    I've looked at the GeoLocate app from Exchange and was going to add to my app. I've not tried it yet, but curious, are you getting an error on Mobile version? or does it simply not load.

    Not sure if this is related, I've also been working with Map reports and Map report will not display on Mobile version on smartphone/tablet, but will display if I switch to the Full Site on my smartphone/tablet.
  • Hi Ruby, Yes we are getting the error on mobile, where its not loading.  We have to resolve it soon, so will give it a hard push in December. Unfortunately our users in the field cant revert back to desktop, so we have to resolve it.
  • I hired Trinity IS, a QSP, to get this working for me. Contatct me if you want the contact at Trinity. QuickBaseCoach.com
  • There are many problems with your code - too numerous to reply to each issue.

    Mixing JavaScript into your formulas is a bad idea. You want to get out of the formula language as quickly as possible and do everything in script. Setting async to false is a bad idea. The variable addURL is appended to but never defined. The date processing is too complex. If you want a fix feel free to contact me off-world using the information in my profile:


    https://getsatisfaction.com/people/dandiebolt