- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在开发一个必须加载 3 种不同 map 类型的应用程序。
MKMapTypeSatellite 工作正常,但在 MKMapTypeStandard 和 MKMapTypeHybrid 中加载 map 时。它调用以下委托(delegate)方法
- (void)mapViewDidFailLoadingMap:(MKMapView *)mapView withError:(NSError *)error;
它给我以下错误。
UserInfo={SimpleTileRequesterUnderlyingErrors=( “错误域=GEOErrorDomain 代码=-204\”(空)\“用户信息={HTTPStatus=410,NSErrorFailingURLStringKey= http://gspe19.ls.apple.com/tile.vf?flags=1&style=1&size=2&scale=0&v=11043961&z=12&x=660&y=1590&sid=1311957767904651942802757092322405105280&accessKey=1462435981_hSWhfZAWqY7wbLSz_6yKz632EUigAIfHlARfHz5OZnObk4SFpRyFZH9qim7suxznqeD333wldHPDaCADTpx1hD98l55WMoqg6qjh2BMyZtDwLayiLzpSWLxfuYD4Oi%2BI3wB%2BGvMwttokk5y8UlnR1E68zLU6KuXF4MWLKLhvv%2F6utSC8RDmorsQksacSTvCwYc45PeV5ba%2Fjvt2d3 }”...
我正在切换 map 类型
-(IBAction)valuechange:(id)sender{
switch (((UISegmentedControl *) sender).selectedSegmentIndex) {
case 0:
_mapView.mapType = MKMapTypeStandard ;
break;
case 1:
_mapView.mapType = MKMapTypeSatellite ;
break;
case 2:
_mapView.mapType = MKMapTypeHybrid ;
break;
default:
break;
}
更新:我想我有类似的问题 MKMapView fails to load tiles with HTTP 410 error
当我重新启动模拟器时。现在 map 加载完美。同样,我的客户告诉我,如果他在他的设备 map 上终止应用程序,则可以完美加载。但是每个新加载的应用程序都有这个问题。我现在很沮丧。 :(
最佳答案
此代码对我有用。如果您有一些修改,请查看下方。
- (void)viewDidLoad {
[super viewDidLoad];
mapView = [[MKMapView alloc]initWithFrame:
CGRectMake(10, 100, 300, 300)];
mapView.delegate = self;
mapView.centerCoordinate = CLLocationCoordinate2DMake(37.32, -122.03);
mapView.mapType = MKMapTypeHybrid;
CLLocationCoordinate2D location;
location.latitude = (double) 37.332768;
location.longitude = (double) -122.030039;
// Add the annotation to our map view
MapAnnotation *newAnnotation = [[MapAnnotation alloc]
initWithTitle:@"MKMapTypeHybrid" andCoordinate:location];
[mapView addAnnotation:newAnnotation];
CLLocationCoordinate2D location2;
location2.latitude = (double) 37.35239;
location2.longitude = (double) -122.025919;
MapAnnotation *newAnnotation2 = [[MapAnnotation alloc]
initWithTitle:@"MKMapTypeHybrid" andCoordinate:location2];
[mapView addAnnotation:newAnnotation2];
[self.view addSubview:mapView];
}
// When a map annotation point is added, zoom to it (1500 range)
- (void)mapView:(MKMapView *)mv didAddAnnotationViews:(NSArray *)views
{
MKAnnotationView *annotationView = [views objectAtIndex:0];
id <MKAnnotation> mp = [annotationView annotation];
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance
([mp coordinate], 1500, 1500);
[mv setRegion:region animated:YES];
[mv selectAnnotation:mp animated:YES];
}
只需更改值mapView.mapType = MKMapTypeStandard;
MKMapTypeStandard、MKMapTypeHybrid & MKMapTypeSatellite
如果你想查看,我也发布了图片。
关于ios - MKMapView 未在 mapType MKMapTypeStandard 和 MKMapTypeHybrid 上加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37046618/
我正在开发一个必须加载 3 种不同 map 类型的应用程序。 MKMapType标准 MKMapTypeHybrid。 MKMapTypeSatellite。 MKMapTypeSatellite 工
我是一名优秀的程序员,十分优秀!