cconstable / LocationPickerView

MKMapView + UITableView + Parallax scrolling. Provides a framework for building an interactive location picker on iOS.
MIT License
223 stars 46 forks source link

How to center on user location when hidden? #7

Closed cerupcat closed 10 years ago

cerupcat commented 10 years ago

I'm using the following code to center on the user's location, but the center point is at the bottom of the visible portion of the hidden map and not in the center of the hidden map. How can I center the map when it's hidden (not expanded)?

MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(user.location.coordinate, 4000, 4000); [self.locationPickerView.mapView setRegion:region animated:YES];

charliefancelli commented 10 years ago

Hi,

There is no simple way to center the map actually, if i have free time i will work on it.

Actually i use a variable (an offset) like this :

- (void)setMapViewToCoordinate:(CLLocationCoordinate2D)coordinate{
    //prendre en compte le décalage
    CLLocationDegrees decalage = -0.0008;
    coordinate = CLLocationCoordinate2DMake(
                                            coordinate.latitude + decalage,
                                            coordinate.longitude
                                            );
    MKCoordinateRegion region = MKCoordinateRegionMake(coordinate, MKCoordinateSpanMake(0.005, 0.005));
    [_locationPickerView.mapView setRegion:region animated:YES];
}
cerupcat commented 10 years ago

Thanks! Using the offset is helpful.

charliefancelli commented 10 years ago

You are welcome.

Can you close the issue ?