标签: mapkit

MKMapView 注释点击事件

当我单击图钉时,会打开带有详细披露按钮的注释视图。
当我触摸详细披露按钮下一个视图被调用时,当我触摸注释时,我需要相同的功能。

objective-c mapkit ios

3
推荐指数
1
解决办法
8851
查看次数

来自国家/地区名称的坐标/区域

如何根据正确书写的国家/地区名称提取CLRegionCLLocationCoordinate2D或纬度/经度点?会CLGeocoder像这样工作:

 CLGeocoder *geoCode = [[CLGeocoder alloc] init];
[geoCode geocodeAddressString:@"Singapore" completionHandler:^(NSArray *placemarks,       NSError *error) {
if (!error) {
      CLPlacemark *place = [placemarks objectAtIndex:0];
NSLog(@"%i,%i", place.//what would i put here);

}


   }];
Run Code Online (Sandbox Code Playgroud)

CLPlacemark告诉地址的变量是什么?

xcode objective-c core-location mapkit ios

3
推荐指数
1
解决办法
1289
查看次数

放大时使用 MKMapView 在 setUserTrackingMode 上崩溃

我有带有 MKUserTrackingModeFollowWithHeading 的 MKMapView。但是有些东西将 userTrackingMode 更改为 MKUserTrackingModeFollow 或 None,所以我实现了,

- (void)mapView:(MKMapView *)mapView didChangeUserTrackingMode:(MKUserTrackingMode)mode animated:(BOOL)animated
{
    if ([CLLocationManager locationServicesEnabled]) {
        if ([CLLocationManager headingAvailable]) {
            [self.myMapView setUserTrackingMode:MKUserTrackingModeFollowWithHeading animated:NO];
        }else{
            [self.myMapView setUserTrackingMode:MKUserTrackingModeFollow animated:NO];
        }
    }else{
        [self.myMapView setUserTrackingMode:MKUserTrackingModeNone animated:NO];
    }
}
Run Code Online (Sandbox Code Playgroud)

一切都很好,但每次我将地图放大到最详细级别时,应用程序都会在上面显示的 setUserTrackingMode:MKUserTrackingModeFollowWithHeading 行中导致 EXC_BAD_ACCESS。

我应该怎么做才能避免崩溃?如果可能,我不想使用 MKUserTrackingBarButtonItem。

mapViewController 的另一部分如下。

- (void)dealloc
{
    self.myMapView.delegate = nil;
}

- (void)viewWillDisappear:(BOOL)animated
{
    if ([CLLocationManager locationServicesEnabled]) {
        self.myMapView.showsUserLocation = NO;
        [_locManager stopUpdatingLocation];

        if ([CLLocationManager headingAvailable]) {
            [_locManager stopUpdatingHeading];
        }
    }

    [super viewWillDisappear:animated];
}

- (void)viewDidAppear:(BOOL)animated
{
    if ([CLLocationManager …
Run Code Online (Sandbox Code Playgroud)

objective-c core-location mapkit ios

3
推荐指数
1
解决办法
2484
查看次数

将搜索字符串从UISearchBar转换为MK MapView地址

将UISearchBar添加到我的MK-MapView,并使用UISearchBar中编写的搜索字符串在地图上获取地址.后来我必须能够转换NSString中地图上指示的地址!你能帮我吗?我在谷歌搜索但我什么都不懂!请帮助我..我使用了这个项目,但是当我运行搜索时,地图仍然是相同的点:我使用的项目

objective-c uisearchbar mapkit mkmapview ios

3
推荐指数
1
解决办法
5195
查看次数

iOS 地图显示特定城市的中心

我正在使用 MapKit 和 CoreLocation 来查找用户位置,然后将其显示在地图上。

我正在使用此代码显示城市和州(这是我感兴趣的,而不是确切位置)。

// this delegate is called when the app successfully finds your current location
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{

    CLGeocoder *geocoder = [[CLGeocoder alloc] init] ;
    [geocoder reverseGeocodeLocation:self.locationManager.location
                   completionHandler:^(NSArray *placemarks, NSError *error) {
                       NSLog(@"reverseGeocodeLocation:completionHandler: Completion Handler called!");

                       if (error){
                           NSLog(@"Geocode failed with error: %@", error);
                           return;

                       }


                       CLPlacemark *placemark = [placemarks objectAtIndex:0];

                       CLLocationCoordinate2D zoomLocation;

                       zoomLocation.latitude = placemark.region.center.latitude;
                       zoomLocation.longitude= placemark.region.center.longitude;

                       MKCoordinateRegion viewRegion = MKCoordinateRegionMakeWithDistance(zoomLocation, METERS_PER_MILE * 2, METERS_PER_MILE * 2);

                       [self.mapView setRegion:viewRegion animated:NO]; …
Run Code Online (Sandbox Code Playgroud)

mapkit cllocationmanager ios

3
推荐指数
1
解决办法
1593
查看次数

为什么MKCircle不会显示在MKMapView iOS8上

我创建了这样的新叠加层:

MKCircle *circle = [MKCircle circleWithCenterCoordinate:region.coordinate radius:region.radius];
[self.mapView addOverlay:circle];
Run Code Online (Sandbox Code Playgroud)

我也实现了委托方法:

- (MKOverlayRenderer *)mapView:(MKMapView *)mapView rendererForOverlay:(id<MKOverlay>)overlay {
    MKCircleRenderer *circleRenderer = [[MKCircleRenderer alloc] init];
    circleRenderer.fillColor = [UIColor greenColor];
    circleRenderer.alpha = 1.f;
    return circleRenderer;
}
Run Code Online (Sandbox Code Playgroud)

代码的两个部分都被调用了,mapView!= nil当时,它是委托集,但是我在地图上看不到圆圈.

我究竟做错了什么?

iphone mapkit mkmapview ios

3
推荐指数
1
解决办法
1750
查看次数

iOS自定义注释:注释引脚下方的视图

我需要用我的自定义注释视图替换默认注释视图.

我需要做以下事情:

  1. 自定义注释视图,其中嵌入了图像视图.
  2. 它下面的视图,其中包含一个标签.

有关更多说明,请参阅图像:

样品针

在上面的图像中,我需要在图像中以圆形形式显示白色空间中的图像视图,接下来我还需要添加一个包含标签的视图,我可以在其上设置任何文本,如我,朋友,等等...

所以,为此,我搜索了关于堆栈溢出的问题,但没有得到我的答案.我不希望它在呼出时,我只是想在渲染地图时将其简单地作为注释.我试图为此制作一个自定义类,但不知道如何处理这个.

任何帮助将受到高度赞赏

objective-c mapkit ios mapkitannotation

3
推荐指数
1
解决办法
2933
查看次数

MKMapViewDelegate:如何在 rendererForOverlay 中识别叠加层

我将两个不同的MKGeodesicPolyline实例添加到MKMapView这样的

CLLocation *LAX = [[CLLocation alloc] ...];
CLLocation *JFK = [[CLLocation alloc] ...];
CLLocation *LHR = [[CLLocation alloc] ...];

CLLocationCoordinate2D laxToJfkCoords[2] = {LAX.coordinate, JFK.coordinate};
CLLocationCoordinate2D jfkToLhrCoords[2] = {JFK.coordinate, LHR.coordinate};

MKGeodesicPolyline *laxToJfk = [MKGeodesicPolyline polylineWithCoordinates:laxToJfkCoords count:2];
MKGeodesicPolyline *jfkToLhr = [MKGeodesicPolyline polylineWithCoordinates:jfkToLhrCoords count:2];

[mapView addOverlay:laxToJfk];
[mapView addOverlay:jfkToLhr];
Run Code Online (Sandbox Code Playgroud)

我想用需要在rendererForOverlay委托方法中配置的不同样式来渲染这两个叠加层。

- (MKOverlayRenderer *)mapView:(MKMapView *)mapView rendererForOverlay:(id <MKOverlay>)overlay {
    if (![overlay isKindOfClass:[MKPolyline class]]) {
        return nil;
    }

    MKPolylineRenderer *renderer = [[MKPolylineRenderer alloc] initWithPolyline:(MKPolyline *)overlay];
    renderer.lineWidth = 3.0f;

    // How to …
Run Code Online (Sandbox Code Playgroud)

objective-c mapkit ios mkoverlay mkoverlaypathrenderer

3
推荐指数
1
解决办法
264
查看次数

如何通过传递地址打开Apple Maps驾驶方向

我正在尝试通过传递实际地址来实现打开Apple Map应用程序的行车方向屏幕的功能.

地址不仅仅是随机地址,而是商业地址,这些地址主要在Apple地图上注册和搜索.因此,通过传递地址,它应该匹配并正确显示该业务的方向,而不是指向地图上的未知注释.当我直接传递经度和纬度时会发生这种情况,因此我不想使用geocodeAddressString()将地址转换为地理协调.

我怎样才能实现它?

mapkit ios apple-maps swift

3
推荐指数
1
解决办法
2226
查看次数

iOS-如何知道我是否需要路由应用程序覆盖文件

我试图将一个应用程序提交到iTunes Connect上的Apple App Store,但收到此错误消息:

“要将此应用程序配置为iOS路由应用程序,请在iTunes Connect上“我的应用程序”中“应用程序的版本”页面上上传路由应用程序覆盖文件。”

我的应用程序使用MapKit来显示用户所在城市中各种古迹的位置,并提供如何到达古迹的指示。我用Google搜索了此错误,有趣的是,回答该问题的大多数人似乎在说实际上不需要该文件,但是我不确定这是否适用于我的应用程序提供的功能。

我怎么知道我是否真的需要路由覆盖文件?而且,如果我确实需要它,我可以使其覆盖全球吗(即该应用程序应该可以在世界上任何地方运行)?

routing itunesconnect mapkit ios

3
推荐指数
1
解决办法
1682
查看次数