I want to show current user location in center and also want to show 15km
distance on all sides from current location. How to achieve that?
Asked
Active
Viewed 401 times
0

Rafał Sroka
- 39,540
- 23
- 113
- 143

user2996143
- 113
- 1
- 9
-
Actually i am developing tourist guide kind of app. In app i need to show custom annotations in app, i have done that part. There is option to show current user location with zoom in. I don't know how to do that. I am very new to map programming. Please can you help me with that. – user2996143 Mar 02 '14 at 08:41
1 Answers
1
Here is how to do it:
- (void)zoomToUserLocationAnimated:(BOOL)animated
{
CLLocationCoordinate2D locationCoordinate2D = _locationManager.location;
CLLocationDistance distance = 30000;
[self setRegion:MKCoordinateRegionMakeWithDistance(locationCoordinate2D, distance, distance)
animated:animated];
}

Rafał Sroka
- 39,540
- 23
- 113
- 143
-
As I know, MKCoordinateRegionMakeWithDistance method accept east-to-west distance in meters, so i need to set 30000 meters for distance. I want to show 15km in all directions from current location with zoom also – user2996143 Mar 02 '14 at 08:50
-
One more thing it will automatically zoom to that region or do i need to set other parameters? – user2996143 Mar 02 '14 at 08:54
-
It will zomm to this region automatically. You don't need to set other parameters. However you need to declare and initialize the `_locationManager` but I guess you have already done this. – Rafał Sroka Mar 02 '14 at 09:55
-
Thanks. Finally i have done that. Can you please tell me when set showUserLocation of mapview to yes, automatically show current location with update? – user2996143 Mar 02 '14 at 10:15
-
-
I have set mapview.showUserLocation = YES, But i want to know that whether it show the location automatically when it updates? – user2996143 Mar 02 '14 at 10:19
-
Yes, the annotation for current user location will update automatically when the location changes. You can test it in simulator by setting a custom location. – Rafał Sroka Mar 02 '14 at 10:20