我的调试信息低于调试信息,而地图根本没有加载。
Trying to initialize GEOVectorTile (2047.2047.12 GEOTileSetStyle_VECTOR_ROADS, GEOTileSize_PX512, GEOTileScale_NODPI) with non-VMP4 data.
答案 0 :(得分:1)
下面是缩放到当前位置的代码。
mpView.showsUserLocation = YES;
[mpView setCenterCoordinate:mpView.userLocation.location.coordinate animated:YES];
[mpView showAnnotations:mpView.annotations animated:YES];
这里我创建了一个按钮,点击按钮我可以轻松导航到当前位置。
-(void)btnCurrentlocationClicked:(id)sender
{
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(ApplicationDelegate.locationManager.location.coordinate, 250, 250);
[mpView setRegion:region animated:YES];
[mpView setCenterCoordinate:mpView.userLocation.location.coordinate animated:YES];
// [mpView selectAnnotation:mapPin animated:YES];
[mpView showAnnotations:mpView.annotations animated:YES];
}
这是我的VierForAnnotation方法
- (MKAnnotationView *)mapView:(MKMapView *)mapview viewForAnnotation:(id <MKAnnotation>)annotation
{
NSLog(@"viewForAnnotation");
if ([annotation isKindOfClass:[MKUserLocation class]]) {
NSLog(@"Is the user %f, %f", [annotation coordinate].latitude, [annotation coordinate].longitude);
// MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(ApplicationDelegate.locationManager.location.coordinate, 250, 250);
// [mpView setRegion:region animated:YES];
return nil;
}
static NSString* AnnotationIdentifier = @"AnnotationIdentifier";
MKAnnotationView *annotationView = [mpView dequeueReusableAnnotationViewWithIdentifier:AnnotationIdentifier];
NSString *strAnnotationSubtitle = [(MKPointAnnotation *)annotation subtitle];
if (annotationView == nil)
{
annotationView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier: AnnotationIdentifier] ;
}
else
{
annotationView.annotation = annotation;
}
annotationView.draggable=YES;
annotationView.canShowCallout = YES;
if([strAnnotationSubtitle isEqualToString:@"Pickup"])
{
annotationView.image = [UIImage imageNamed:@"ic_pin_pickup"];
}
else if ([strAnnotationSubtitle isEqualToString:@"Drop"])
{
annotationView.image = [UIImage imageNamed:@"ic_pin_drop"];
}
return annotationView;
}
//您可以根据自己的要求进行自定义。