theiOSDude
theiOSDude

Reputation: 1470

iphone uimapview to zoom to level of accuracy

just a quick one - i can get the location of the user, i can set the zoom level - but how do i go about setting the zoom level to be respective of the accuracy.

So i would be zoomed quite far out if accuracy is poor, and zoomed quite far in if accuracy is good.

Bound to be simple, im just overlooking something here.

cheers

Upvotes: 1

Views: 473

Answers (2)

user467105
user467105

Reputation:

In the CLLocationManager's didUpdateToLocation delegate method, you can use the horizontalAccuracy property in the newLocation parameter and create a region from it using the MKCoordinateRegionMakeWithDistance function:

MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance
                                (newLocation.coordinate, 
                                 newLocation.horizontalAccuracy, 
                                 newLocation.horizontalAccuracy);

The horizontalAccuracy is being passed for both the latitude and longitude spans.

Upvotes: 3

FelipeDev.-
FelipeDev.-

Reputation: 3143

@burrows111 You can set the region to show to the user with MKCoordinateRegion region; region.center = userLocation; MKCoordinateSpan span; span.latitudeDelta = yourDistanceFilter; span.longitudeDelta = yourDistanceFilter; region.span = span;

Then, the current location will be centered in a region that u determinate in your "yourDistanceFilter", so this value could be different depending of the accuracy.

Upvotes: 0

Related Questions