I want to locate if I/friend have entered in a certain region on map using mapkit. this region could be a town or city or a place of any radius. i have not found any help regarding, any help or even a way towards the goal would be highly appreciated.
PEACE
There is a method on CLLocationManager which will let you do this: startMonitoringForRegion:, you pass a CLRegion which is basically just a point and a radius and it will call CLLocationManagerDelegate methods when the user enters or exits this region
Its just an idea. Refresh the app constantly at a distance and pass the current lat/long value to the server using webservice. And if current lat/long value is same as some specific lat/long then show UIAlertView. Hope that helps.
Related
I am new to iphone development.I want to know whether there is any method to check a person iphone is pointing towards a particular location or not.I cam to know that there is framework for CLLocation to get the heading of the device.But i also want to check if its poiting towards the right direction also. Destination location is obtained by longitude and latitude.Can any one suggest me a method for it?
thanks in advance
CLLocationManager will give you the heading, Check out the docs here-> https://developer.apple.com/library/mac/ipad/#documentation/CoreLocation/Reference/CLLocationManager_Class/CLLocationManager/CLLocationManager.html
Also, check out this answer where they talk about CLLocationDirection and trueHeading -> https://stackoverflow.com/a/2043694/1104563
--- UPDATED
There is no built-in way to do this, you need to use a formula to determine this. The formula can be found here calculate bearing in relation to two points
In addition you can check out this SO answer:
CLLocation Category for Calculating Bearing w/ Haversine function
Hope this helps. Good luck!
I am implementing map based application in iPhone sdk. I want to give functionality in map view like Google maps directoins. means is at some location from that he selects one pin from multiple pins from MKPinAnnotationView. is it possible that user can get direction from his current location to selected pin location in MapView? user can select any aanonations from that he can get directions in some way of line to his current location to pin location. i have get some idea from here
but this all was some static data you can download this example.
here also apple example. but this example is only for track & draw line for user movement.
is it possible that user can get direction from his current location to selected pin location in MapView?
Yes. You can send a query to google maps api using your current location and the selected annotation location. When google responds with the route, you will use that polyline decoder method to decode the data and draw the route on your map view.
I have got all side idea from here
this can be useful for other developers also.
i have found some other examples also that can be also useful for other developers just google. you will find this is polyline link for user current location use this apple code
Here is Google direction api. Read it and use it.
For test purpose you can check this request
http://maps.googleapis.com/maps/api/directions/json?origin=28.459497,77.026638&destination=28.435600,77.009997&sensor=true
And use JSON Viewer to see the json response.
I'm writing an app that stores the location of the places you have been throughout the day. I've done a lot of research on CLLocationManager, and have been testing my app for the last 3 weeks. The locations I get with CLLocationManager sometimes is very inaccurate, sometimes 4 or 5 miles away from where I am.
I have a log in my test app and realized that every time I get a new location my DidUpdateToLocation method is called 3 times in a row, like within one second, and I get 3 different locations. One of them is always right, but the other 2 are off. I've tested with it with different accuracies(hundredMeters, nearestTenMeters, and Best), but still had the same problem. So, my first question is:
Is there anyway I can find out which of these locations is the right one so I can store it?
I've also realized that the user's current location on the map view is always very accurate, so I thought about getting the user's location from the mapView(blue dot) instead of the CLLocationManager, but I learned that a mapView object will only return the current location if the map is actually on screen, and this is not the case since I want my app to run in the background. So the second question is:
Is there anyway to get the user's current location from a mapView without the map being on screen? Or at least use the same technique the mapView uses for finding the current location?
If you have any experience with mapKit and CLLocationManager, please share your thoughts.
Thanks for you time. Any help is appreciated.
Is there anyway I can find out which of these locations is the right
one so I can store it?
Look at the horizontalAccuracy property of the locations that you receive. Don't use locations that are less accurate than what you're looking for.
I've also realized that the user's current location on the map view is
always very accurate
The map view probably doesn't have any special access to API's that are more accurate than what you've got, it just uses them better. Instead of starting from scratch each time you need a fix, try caching the location and then updating when you get a new location that's sufficiently accurate.
Take a look at Apple's sample code Locate Me. It uses the variable:
CLLocation *bestEffortAtLocation;
to determine upon updates if the location is less than the last location and less than a time limit set until the most accurate location is found.
In particular look at the GetLocationViewController in the sample code. I've used this code in my apps and it works great.
https://developer.apple.com/library/ios/#samplecode/LocateMe/Listings/Classes_GetLocationViewController_m.html#//apple_ref/doc/uid/DTS40007801-Classes_GetLocationViewController_m-DontLinkElementID_8
In my iOS app, a mapkit object displays the user's current location and zooms in on it.
I would like to put that code into an if statement so that it will only happen when the user is within a specified geographic region (a specific country, city etc).
Any help will be hugely appreciated.
Thanks,
Roy
Some Resources I found useful.
CLLocationManager Class Reference
CLRegion Class Reference
Core Location region monitoring
I need put information about place, where is iPhone now, to UILable in my screen. [Country][City][Street] and maybe coordinates [lat][lng]. For example in my UILable should be:
Your location is German, Berlin, Tiergarten
Can someone show me really simple code how can i get such information that put in my UILable?
The MapKit framework (part of iPhone OS 3.0) provides this for you. Specifically the MKPlacemark object, which you can obtain for a set of co-ordinates using an MKReverseGeocoder.
You need access to a reverse geocoding service, which will take your lat/lon coordinates as input and return some kind of structured address of that location.
Google's is available here: http://code.google.com/apis/maps/documentation/geocoding/index.html#ReverseGeocoding