Tag: mapkit

MapKit注解没有显示在地图上

我无法在MapKit的地图上显示MKAnnotationViews。 我正在使用iOS 7,现在已经在论坛和网上search了很多小时,尝试了不同的样本和设置。 下面我有最基本的设置可能(我认为)使其工作。 该应用程序包含一个单独的ViewController,顶部有一个button,剩下的就是MapView。 该button触发方法zoomToUser:(UIBarButtonItem *)发件人。 右键点击并检查我的网点和代表似乎是正确的。 我有一些NSLog语句被触发输出一些debugging信息。 首先是VC: #import "ViewController.h" #import "Data.h" @interface ViewController () <MKMapViewDelegate> @property (weak, nonatomic) IBOutlet MKMapView *mapView; – (IBAction)zoomToUser:(UIBarButtonItem *)sender; @end @implementation ViewController – (void)viewDidLoad { [super viewDidLoad]; self.mapView.showsUserLocation = YES; Data *ann = [[Data alloc] init]; [self.mapView addAnnotation:ann]; } -(void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; [self zoomToUser:nil]; } -(IBAction)zoomToUser:(UIBarButtonItem […]

无法让UIMapView“缩放”/ setRegion:当地图首次加载时

我有一个UIViewController加载一个地图上已经有一堆针脚。 有没有问题让引脚出现,但我似乎无法让用户第一次到达mapView时MKMapView执行setRegion。 我试着把代码放在可能工作的所有可能的方法中, mapViewWillStartLoadingMap , viewWillLoad , mapViewWillStartLoadingMap , mapViewDidFinishLoadingMap等都无济于事。 然而,如果我返回到前一个viewController,然后再次进入包含mapView的viewContoller,它将“缩放”到指定区域。 有没有这样做的超级秘密方式,我不知道? 不应该调用[mapView setRegion:(…) animated:YES]; 足以让地图“缩放”/更新显示选定的区域? 此外,如果有人知道如何获得引脚(我正在使用MKPointAnnotation为我的)animation下降,以及得到的地图animation放大,(既不这样做,虽然我设置animation…. ),我会很感激这个信息。 谢谢! 码: @implementation FindOnMapMapView @synthesize mapView; @synthesize mapViewTabBarItem; @synthesize results; @synthesize reverseGeocoder; – (void)viewDidLoad { [super viewDidLoad]; NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; MKCoordinateRegion mapRegion = MKCoordinateRegionMake(CLLocationCoordinate2DMake([defaults doubleForKey:@"latitude"], [defaults doubleForKey:@"longitude"]), MKCoordinateSpanMake(0.744494189288569, 0.744494189288569)); mapView.region = mapRegion; [mapView setRegion:mapRegion animated:YES]; […]

改变用户位置周围的脉冲蓝色环的颜色

我search了网页,还没有find一种方法来定制用户在地图上的位置周围的蓝色脉冲环的颜色。 有谁知道一种方法来定制脉冲环的颜色?

在iphone mkmapview中获取地图的当前位置

我怎么能得到在mkmapview的位置坐标根据用户在他们的iphone上触摸地图上的位置?

如何:在MKMapView上显示MKOverlay

我需要在地图上显示MKOverlay,但无法实际显示。 我正在关注苹果“ 位置感知编程指南”中的示例 ,并且不会显示覆盖图。 任何帮助将不胜感激,这是我所做的第一个iPhone应用程序,所以我可能会错过简单的东西。 NavViewController.h #import <UIKit/UIKit.h> #import <MapKit/MapKit.h> @interface NavViewController : UIViewController <MKMapViewDelegate> { } @property (weak, nonatomic) IBOutlet MKMapView *mapView; @end NavViewController.m #import "MSUNavViewController.h" #import <CoreLocation/CoreLocation.h> – (MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay:(id <MKOverlay>)overlay { if ([overlay isKindOfClass:[MKPolygon class]]) { MKPolygonView* aView = [[MKPolygonView alloc] initWithPolygon:(MKPolygon*)overlay]; aView.fillColor = [[UIColor cyanColor] colorWithAlphaComponent:0.2]; aView.strokeColor = [[UIColor […]

自定义MKOverlayView /未经修改的MKPolygonView在某些缩放级别被剪辑

我有一个自定义的MKOverlayView和标准的MKPolygonView被裁剪在某些缩放级别的问题,当有多个叠加添加到地图。 阿尔及利亚在两个双击缩放级别叠加。 阿尔及利亚在三个双击缩放级别的叠加。 注意裁剪。 几点意见: 无论是否使用自定义MKOverlayView或返回具有相同多边形的MKPolygonView,都会发生这种情况。 如果我只绘制一个覆盖,这个问题不会发生。 这不会发生在所有覆盖 – 只有一些。 至于代码:这将覆盖添加到一个NSMutableArray(borderOverlays),然后访问其他地方加载覆盖特定的国家ID。 minX / minY / maxX / maxY是纬度/经度值; 多边形是由ESRI shapefile构build的path。 CLLocationCoordinate2D mbrMin = CLLocationCoordinate2DMake(minY, minX); CLLocationCoordinate2D mbrMax = CLLocationCoordinate2DMake(maxY, maxX); MKMapPoint minPoint = MKMapPointForCoordinate(mbrMin); MKMapPoint maxPoint = MKMapPointForCoordinate(mbrMax); MKMapSize size = MKMapSizeMake(maxPoint.x – minPoint.x, maxPoint.y – minPoint.y); MKMapRect rect = MKMapRectMake(minPoint.x, minPoint.y, size.width, size.height); if […]

我怎样才能迅速将用户的位置中心地图?

我正在写一个应用程序,我有一个embedded式的地图视图来显示用户的位置。 这是我的代码到目前为止: class YourCurrentLocation: UIViewController, CLLocationManagerDelegate { @IBOutlet weak var mapView: MKMapView! var locationManager = CLLocationManager() let regionRadius: CLLocationDistance = 1000 func checkLocationAuthorizationStatus() { if CLLocationManager.authorizationStatus() == .AuthorizedWhenInUse { mapView.showsUserLocation = true centerMapOnLocation(locationManager.location!, map: mapView, radius: regionRadius) } else { locationManager.requestAlwaysAuthorization() //requestWhenInUseAuthorization() } } func centerMapOnLocation(location: CLLocation, map: MKMapView, radius: CLLocationDistance) { let coordinateRegion = […]

在mapview iOS 6中绘制折线

您好我正在做一个应用程序,必须显示与路线的地图。 我parsing了Json以获取绘制折线的点。 我在网上find了一个代码来绘制这条折线。 代码我发现它在这个链接: http : //iosguy.com/2012/05/22/tracing-routes-with-mapkit/ 它说“创buildMKPolyline批注”我试图导入这个在我的应用程序,但我有问题来创build坐标的数组。 我的方法是这样的: – (void)createMKpolylineAnnotation { NSInteger numberOfSteps = self.path.count; CLLocationCoordinate2D *coords = malloc(sizeof(CLLocationCoordinate2D) * numberOfSteps); for (NSInteger index = 0; index < numberOfSteps; index++) { CLLocation *location = [self.path objectAtIndex:index]; CLLocationCoordinate2D coordinate = location.coordinate; coords[index] = coordinate; } MKPolyline *polyLine = [MKPolyline polylineWithCoordinates:coords count:numberOfSteps]; [self.mapView addOverlay:polyLine]; } 当我试图只看第一次设定坐标的价值时,为什么呢? […]

如何清除mkmapview的caching

在我的应用程序中,我有一个文本框和一个searchbutton。当用户点击searchbutton后填充文本字段上的地址我的应用程序显示结果,并在地图视图上放置一个pin。 我正在使用谷歌地图API。 我还添加了用户可以拖放的function。 当用户拖动引脚,并放在另一个地方。以前的引脚应该被删除。为了去除这个引脚,我正在使用[mapView removeAnnotation [mapView.annotations lastObject]]; 但是当我再次search一个已经search的新地址时,它又创build了一个新的引脚。 我知道这是来自mkmapview的caching。 **现在我怎么能从mkmapview中删除它(pin)

添加MKOverlayPathRenderer作为覆盖MKMapView获取exception

一切都在主题中说,所以这里是代码 – (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. _pathRenderer = [[MKOverlayPathRenderer alloc] init]; _pathRenderer.lineWidth = 8.0f; _pathRenderer.strokeColor = [UIColor redColor]; _pathRenderer.path = CGPathCreateMutable(); [_mapView addOverlay:_pathRenderer]; } 在最后一行,它会抛出exception: Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[MKOverlayPathRenderer boundingMapRect]: unrecognized selector 这意味着我使用错误的类,没有实现MKOverlay,我明白了,但正如参考MKOverlayPathRenderer所说 – 它的确如此。 所以我有点卡住了这个问题。