In many iPhone application development projects that I have done, I had to work on Geo-fencing feature i.e. It should prompt an alert to user (“You are nearby X place”) when user is passing through any location within certain radius.

So when I was developing such iOS applications, it was practical and assumed that I cannot go to all places and test the application, so for such kind of testing with live records I have used below function to change/transfer user’s geo-location to any particular area.

For this you have to take arbitrarily any location and use your current location to find out offset values and get it done as explained below. To transform any location to any other area on geographical plan you need to apply offset values on the current latitude and longitude of user location.

Kindly follow below steps to transform any points to other plan. It is explained using one of the iOS features related to “Settings” bundle. Because that way you can change offset very quickly without doing statically within an application.

How to create setting bundle with Offset points ?

Add setting bundle into your application:

Adding Setting Bundle in App

Add two text field and set their values as shown in below image.

Adding Values

In a common method class or in application delegate file you will have to write down below two methods. One method is responsible to apply offset value on latitude for current location and another is for longitude.

Method-1:

 

Method-2:

How to calculate Offset Values to set under “Settings” ?
You need to have your current location and desire location where you would like to move your current position. Below examples shows how you can calculate offset value.

Example:

Current Location:
Latitude : 23.031715
Longitude : 72.565338

Desired Location:
Latitude : 37.578313
Latitude : -122.347146

Offset values:
Latitude Offset : (37.578313 – 23.031715) = 14.546598
Longitude Offset : (-122.347146 – 72.565338) = -194.912484

How to set offset value in an application?
Once you install application in your device, go to default settings it will list your application under it.

Once you select your application – you will find screen like below where you need to enter your calculated offset values.
Set offset value in App

 

How to apply offset values on current location?
Please find below sample code using which you can apply offset on the current location.

 

This is how we can transform our current location to any other point.

iOS Team @ Weblineindia

iOS Team @ Weblineindia

We are iOS Team @ Weblineindia. We are energetic, adaptive and enthusiastic to explore our limits in this dynamic world of Mobile App Development. We always remains up-to-date with industry standards and trends that are followed for mobile application development. We have so far delivered applications in various domains like Business, Health & Fitness, Social Networking, Utilities and many more. We have also delivered many enterprise applications and complex architecture applications which follows SAAS model. We have expertise in developing iPhone / iPad Applications, Universal Apps, iWatch Applications and Mac OS Applications which includes many rich features like offline data storage using core data / sqlite framework, cloud based APIs, usage of widgets and extensions, push notifications, in-app purchase functionality, siri enabled features and many more. As a team, we are always eager to contribute back to the community and so happy to help here to our developer community on any technical problems and discussions. Contact us if you want to develop any kind of iOS app.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *