我在我的应用程序中使用MapKit并且使用了用户位置
[mapview setShowUserLocation:YES];
Run Code Online (Sandbox Code Playgroud)
我想用userLocation的坐标设置region.center.latitude和region.center.longitude,怎么做?
我有这样的方法:
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
Run Code Online (Sandbox Code Playgroud)
使用它,我可以获得坐标吗?
我需要知道从中心地图到屏幕另一侧的距离(以千米为单位)(如果变焦改变,距离将改变).
我需要在这个函数中实现这个功能
- (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated{
}
Run Code Online (Sandbox Code Playgroud)
我有什么想法可以做到这一点?
谢谢
Realtor iPad应用程序在mapkit之上实现了一个自定义绘图工具,用于查询家庭区域.我熟悉mapkit及其相关的类,但我不知道如何用手指做一些自定义绘图并将其转换为地理空间查询.怎么做?
在iOS 6中使用MapKit,我应该如何在没有特定坐标的情况下到达附近的位置?我也不确定它是否仍有可能......错误...... 允许 ......使用Google Maps API来实现这一目标,因为这是我能想到的唯一方法.
我知道所有内容仍处于测试阶段,但我仍然没有在任何地方找到有关此主题的信息,无论是在论坛上,在Apple的新MapKit文档中.我想要做的就是在用户位置的'x'英里内搜索位置(例如,公园).
看来,既然Apple开发了自己的Maps应用程序,他们应该有办法使用MapKit或Core Location来实现这一点......对吗?
我编写了简单的应用程序,它在MapKit上的两个位置之间绘制路径.我正在使用Google Map API.我使用了我在网上找到的资源,这里是我用来向Google提出请求的代码:
_httpClient = [AFHTTPClient clientWithBaseURL:[NSURL URLWithString:@"http://maps.googleapis.com/"]];
[_httpClient registerHTTPOperationClass: [AFJSONRequestOperation class]];
[_httpClient setDefaultHeader:@"Accept" value:@"application/json"];
NSMutableDictionary *parameters = [[NSMutableDictionary alloc] init];
[parameters setObject:[NSString stringWithFormat:@"%f,%f", coordinate.latitude, coordinate.longitude] forKey:@"origin"];
[parameters setObject:[NSString stringWithFormat:@"%f,%f", endCoordinate.latitude, endCoordinate.longitude] forKey:@"destination"];
[parameters setObject:@"true" forKey:@"sensor"];
NSMutableURLRequest *request = [_httpClient requestWithMethod:@"GET" path: @"maps/api/directions/json" parameters:parameters];
request.cachePolicy = NSURLRequestReloadIgnoringLocalCacheData;
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc]initWithRequest:request];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject){
NSInteger statusCode = operation.response.statusCode;
if (statusCode == 200)
{
NSLog(@"Success: %@", operation.responseString);
}
else
{
NSLog(@"Status code = %d", statusCode);
}
}
failure:^(AFHTTPRequestOperation …Run Code Online (Sandbox Code Playgroud) 我在互联网上搜索但我找不到答案.可以在MKPolygon中画一个洞吗?像这样的东西:

我记得我看过这样的东西,但我不确定它是否与iOS有关.有可能这样做(如果是的话)我应该如何开始?
谢谢
在我的应用程序中,我使用MKMapView在地图视图上显示一些位置.它显示地图很好.但从昨天开始它只显示网格而不显示地图,当我添加委托方法时,它会在mapviewdidfiailtoload中显示.
我使用以下代码
// MapView类
myMapView=[[MKMapView alloc] initWithFrame:CGRectMake(0,gameNameLabel.frame.size.height, 320, 181)];
myMapView.mapType=MKMapTypeStandard;
myMapView.delegate=self;
LocationModel *loc=presentGame.location;
NSArray *cordinates=[loc.geoCordinates componentsSeparatedByString:@","];
CLLocationCoordinate2D zoomLocation;
zoomLocation.latitude = [[cordinates objectAtIndex:0] doubleValue];
zoomLocation.longitude= [[cordinates objectAtIndex:1] doubleValue];
MKCoordinateRegion viewRegion = MKCoordinateRegionMakeWithDistance(zoomLocation, 0.5*METERS_PER_MILE, 0.5*METERS_PER_MILE);
// 3
MKCoordinateRegion adjustedRegion = [myMapView regionThatFits:viewRegion];
// 4
[myMapView setRegion:adjustedRegion animated:YES]; [scroll addSubview:myMapView];
Place *pin = [[Place alloc] init];
pin.name = loc.gameLocation;
pin.latitude = [[cordinates objectAtIndex:0] doubleValue];
pin.longitude = [[cordinates objectAtIndex:1] doubleValue];
PlaceMark* Place1 = [[PlaceMark alloc] initWithPlace:pin];
Place1.tagg=1;
[myMapView addAnnotation:Place1];
//end of mapview
Run Code Online (Sandbox Code Playgroud)
- (MKAnnotationView*)mapView:(MKMapView*)mapView1 …
我已经阅读了其他StackOverflow问题和解答,并了解这是自iOS6以来的一个错误(或者通过设计,必须解除分配代理,然后查看,谁知道).我不知道为什么或如何没有修复.
Anywho,我已经从其他答案添加了热门修补程序(下面,对于未来的读者):
- (void) viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
[self applyMapViewMemoryHotFixOnDisappear];
}
- (void)applyMapViewMemoryHotFixOnDisappear{
[self applyMapViewMemoryHotFix];
self.mapView.showsUserLocation = NO;
self.mapView.delegate = nil;
self.locationManager.delegate = nil;
[self.mapView removeFromSuperview];
self.mapView = nil;
}
- (void)applyMapViewMemoryHotFix{
switch (self.mapView.mapType) {
case MKMapTypeHybrid:
{
self.mapView.mapType = MKMapTypeStandard;
}
break;
case MKMapTypeStandard:
{
self.mapView.mapType = MKMapTypeHybrid;
}
break;
default:
break;
}
self.mapView.mapType = MKMapTypeStandard;
}
-(void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated
{
[self applyMapViewMemoryHotFix];
}
Run Code Online (Sandbox Code Playgroud)
但是,我的问题是,为什么内存不会降到MapKit级别之前?

还有什么我想念的吗?这是预期的行为吗?分析器判断没有内存泄漏,但显然有些事情是不对的......
我实现了一张地图,效果很好.但是当我尝试放大地图时,我发现这个问题面临:
这是我的代码:
- (MKOverlayRenderer *)mapView:(MKMapView *)mapView rendererForOverlay:(id<MKOverlay>)overlay
{
MKPolylineRenderer *renderer = [[MKPolylineRenderer alloc] initWithPolyline:(id)overlay];
renderer.strokeColor = [UIColor redColor]; // pathColor;
renderer.lineWidth = 7.0;
return renderer;
}
Run Code Online (Sandbox Code Playgroud) mapkit ×10
ios ×7
iphone ×6
objective-c ×6
mkmapview ×3
apple-maps ×1
ios6 ×1
ios8 ×1
ipad ×1
memory-leaks ×1
mkoverlay ×1