Jump to content

Match Geolocation Coordinates To User's Location


Go to solution Solved by juancoffee,

Recommended Posts

Hello All

 

I want to restrict what geographic location users can submit my forms from.

Basically, I want the form to look up the latitude and longitude and match it against ones on my table.

Then (within a couple of hundred feet or so) I want it to either-

 

  • Accept the location the user is at as being the one I've agreed and submit the data 
  • Don't accept the user's location (they are more than a couple of hundred feet away from the latitude and longitude on my table) and put up an error message 'Sorry - you are not in the right location to complete this form'.

I know this can be done, but it is way above my technical ability I'm afraid.

 

Any help from you wonderful useful people out there?

 

Your hopefully

 

Duncan

Link to post
Share on other sites

Hi Jan

 

Thanks for this.

Yes, I'd seen that article.

 

The bit I can't do however is take that data and compare it against set data in my tables.

With a little fiddling about, I can get the 'lat' and 'long' to compare against those that I have specified.

 

I started to get really confused though when i tried to build some tolerance in.

If the acceptable area is a reasonable size (a sports hall, or supermarket for example) then the specific latitude and longitude only will be too restrictive.

 

That was when my brain (which is admittedly very small) started to melt down...

 

Duncan

 

 

Link to post
Share on other sites

Hi Duncan,

 

It seems I have found a solution. I am not sure that it is the best way.

A user enters his coordinates on a Reports DataPage. On Results page the tables is hidden, the Java Script checks whether message "No records found" is displayed. If yes, error message is displayed and the Search form is displayed again. Else a user is redirected to a Submission form, where he/she enters a data.

 

Please try next steps:

1) Create a Reports DataPage, add the Distance Search By Coordinates on the Select Search Fields step.

2) On the next step, select the Distance field, select the Hidden in the Form element drop down box and enter your Default Value.

3) On the Configure Results Page Fields, add the following code to the Header:

<div align="center"> <p>Processing...</p></div>

4) On the Configure Results Page Fields, add the following code to the Footer:

<script type="text/javascript">
if(document.getElementById("caspioform"))
{
document.getElementById("caspioform").style.display = 'none';
var place_is_found = 1;
var elems = document.getElementsByTagName("p");
for (var i=0, m=elems.length; i<m; i++) 
   {
       if (elems[i].innerHTML== "No records found. Please, enter more short query.")
         {
            place_is_found = 0;
         }    
    }
if (place_is_found==1)
    {
        window.location = "http://www.caspio.com/";
    }
else
   {
        alert("Warning message");
        window.history.back();
   }
}
</script>

Please enter the address of your DataPage instead of "http://www.caspio.com/".

Also enter your message instead of "Warning message".

 

I hope it helps.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...