Add GeoLocating to your Mobile Iron Speed Application
Bryan Patrick –Pseudo Consulting
April 10, 2012
Iron Speed added some great features with Version 9, especially generating Mobile Applications. Since most mobile phones have built-in GPS location, utilizing that information adds even more value to your application.
Here is way to add “Geolocating” to an Iron Speed application and use that information to provide information to the user based on their current location.
You can see this application in use at http://closest.alndata.com
First off we need some data. In one of my databases, I have apartment information with GPS coordinates for over 21,000 apartment communities around the United States.
Here are the steps I used to create a test application that will display up to the 50 closest apartment communities to you along with the distance from you to them. This is just a sample application. In a real-world application, you would display more information about the properties, driving direction, or could display a map of the closest properties.
Step 1: Create a view in your database that has 3 columns. An Id column, a Property Name column and a Distance column. We are not actually going to use this view. At run-time we will replace the data from the output of a stored procedure. The view is just to create a table control in your mobile Iron Speed application.
Step 2: Add a drop down list for the Property Count, a Latitude textbox, a Longitude textbox and a “Go” button.
Step 3: Right-Click and add the following code to your page directives:
This code will cause your phone to load your current GPS coordinates into the 2 textboxes. The first time you hit your application’s page you’ll get the notice from your phone that your browser is trying to access your curent location.
Be sure to “Allow” your browser to access your location information.
Step 4: Add a ShowTable for your view. Hide the Drop-Down icon and Pagination controls. I set the page length to 100 to handle all possible values from my “count” control. For the fields, I selected the AptName field and Distance. Again, the view itself is not being using to generate data. We are going to call a stored procedure and “Add Rows” ourself to the displayed data in order to display the information.
Step 5: Set the properties for the “Show Closest Properties” button to apply the search and filter to the view’s TableControl.
Step 6: We need some data! Here is my stored procedure which, given a GPS location and count N, returns the N closest properties in order of distance.
Step 7: Now we just need to tie it all together. We can modify just 1 function of the TableControl, the LoadData() function.
Modify the LoadData() function removing these 2 lines:
And replacing them with the following:
These changes check for some input values, pass them to the stored procedure, then add rows in our TableControl for each record retrieved from the stored procedure.
How it looks
Here are actual screen captures from my iPhone 4 after lunch today:
About the Author
C. Bryan Patrick II has been a professional database developer since the age of 16. He has a Bachelor of Arts in Computer Science from The University of Texas at Austin. At 26 Bryan received a US Patent (# 5,142,624) for work done during his college years. He is a member of the Microsoft Partner Program and has been self-employed for the last 10 years as a small business IT consultant and web application developer.