English 中文(简体)
• 如何把我目前的所在地点放在MKMap 的意见中?
原标题:How to center my current location in MKMapView?

兹在上显示<代码>的现行。 可通过<代码>查询<>。 我还希望把<条码>地图><>>查询/编码>集中到目前用户所在地点,并标明地点分布式图。 在我没有从其他类似问题获得任何帮助时,请帮助我解决这一问题。

我的法典如下:

- (void)viewDidLoad {
  [super viewDidLoad];
  [mapView setMapType:MKMapTypeStandard];
  [mapView setZoomEnabled:YES];
  [mapView setScrollEnabled:YES];
  [mapView setCenterCoordinate:mapView.userLocation.location.coordinate animated:YES];
  [mapView setDelegate:self];
}
最佳回答

关于用户所在地点,您可使用以下代码:

[mapView setCenterCoordinate:mapView.userLocation.location.coordinate animated:YES];

为了在特殊地点进行集聚,你应研究区域(<>MKCoordinationRegion)的计算和工作,计算本区域的值,并用电话显示:

[mapView setRegion:myRegion animated:YES];

sample WorldCities 显示了区域展示的基础。

问题回答
MKCoordinateRegion region;
    MKCoordinateSpan span;
    span.latitudeDelta = 0.2;     // 0.0 is min value u van provide for zooming
    span.longitudeDelta= 0.2;

    CLLocationCoordinate2D location = [self addressLocation];
    region.span=span;
    region.center =location;     // to locate to the center
    if(addAnnotation != nil) {
        [mapView removeAnnotation:addAnnotation];
        [addAnnotation release];
        addAnnotation = nil;
    }
    addAnnotation = [[AddressANnotation alloc] initWithCoordinate:location];
    [mapView addAnnotation:addAnnotation];
    [mapView setRegion:region animated:TRUE];
    [mapView regionThatFits:region];

这帮助我表明了地图观点的核心立场。

-(void) removeZoom:(float)deltaValue
{
    MKCoordinateRegion region;
    region.center.latitude =  self.locationManager.location.coordinate.latitude;
    region.center.longitude = self.locationManager.location.coordinate.longitude;

    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.5];
    region.span.latitudeDelta = deltaValue;
    region.span.longitudeDelta = deltaValue;
    region = [mapViewSelf regionThatFits:region];
    [mapViewSelf setRegion:region animated:YES];
    [UIView commitAnimations];

}

页: 1

self.mapView.showsUserLocation = YES;
self.mapView.userTrackingMode = MKUserTrackingModeFollow;




相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...

热门标签