0
如何使用IOS中的mapkit在Map上显示用户。此代码仅在地图上显示印度,而不是定义的坐标。如何使用IOS中的mapkit在地图上显示用户
mapView.delegate = self;
mapView.showsUserLocation = YES;
objLocationManager = [[CLLocationManager alloc] init];
objLocationManager.distanceFilter = kCLDistanceFilterNone;
objLocationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters;
objLocationManager.delegate = self;
#ifdef __IPHONE_8_0
if(IS_OS_8_OR_LATER) {
// Use one or the other, not both. Depending on what you put in info.plist
//[objLocationManager requestWhenInUseAuthorization];
[objLocationManager requestAlwaysAuthorization];
}
#endif
[objLocationManager startUpdatingLocation];
mapView.showsUserLocation = YES;
[mapView setMapType:MKMapTypeStandard];
[mapView setZoomEnabled:YES];
[mapView setScrollEnabled:YES];
mapView.delegate=self;
是的,我已经使用这个委托,并提到的代码的MKCoordinateRegion区= MKCoordinateRegionMakeWithDistance(userLocation.coordinate,800,800 ); [self.mapView setCenterCoordinate:mapView.userLocation.location.coordinate animated:YES]; [self.mapView setRegion:[self.mapView regionThatFits:region] animated:YES];这也不起作用。 –
打印在我的程序中的日志正试图启动MapKit位置更新,而不提示进行位置授权。必须首先调用 - [CLLocationManager requestWhenInUseAuthorization]或 - [CLLocationManager requestAlwaysAuthorization]。 –
添加几行后,显示放大的位置,但不显示地图上的注释。 MKCoordinateRegion viewRegion = MKCoordinateRegionMakeWithDistance(zoomLocation,0.5 * METERS_PER_MILE,0.5 * METERS_PER_MILE); [self.mapView setRegion:viewRegion animated:YES]; –