PaulVorster1
7 years agoQrew Cadet
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);
}
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);
}