标签: mapkit

MKOverlay有时会消失

我的地图中有两个叠加选项:MKCircleOverlay和MKPolygonOverlay.第一个是可变半径,通过UISlider控制.最后一个是根据角的数量和位置自定义.如果我改变非常快的圆的半径(减少UISlider的值)有时候我的叠加层会消失(圆圈),之后不能再绘制多边形了(当然也是圆圈).没有崩溃的应用程序.可能是什么?

这是我使用的一些代码:

- (IBAction) addCircle:(id)sender
{
slider.hidden = NO;
slider.transform = CGAffineTransformMakeRotation(M_PI*(-0.5));

_longPressRecognizer= [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPress:)];
_longPressRecognizer.minimumPressDuration = 1.0; 

[mapview addGestureRecognizer:_longPressRecognizer];
[_longPressRecognizer release];
}

- (void)handleLongPress:(UIGestureRecognizer *)gestureRecognizer
{
if (gestureRecognizer.state != UIGestureRecognizerStateBegan)
    return;
CGPoint touchPoint = [gestureRecognizer locationInView:mapview];    
CLLocationCoordinate2D touchMapCoordinate = [mapview convertPoint:touchPoint toCoordinateFromView:mapview];

MKPointAnnotation *pa = [[MKPointAnnotation alloc] init];
pa.coordinate = touchMapCoordinate;
pa.title = @"Circle Based Search";

[mapview addAnnotation:pa];
[pa release];

tmC = touchMapCoordinate;
double radius = 1000.0;

self.circleOverlay = [MKCircle circleWithCenterCoordinate:tmC radius:radius];
[mapview removeOverlays:[mapview overlays]];
[mapview addOverlay:circleOverlay]; …
Run Code Online (Sandbox Code Playgroud)

iphone mapkit mkmapview ios mkoverlay

8
推荐指数
1
解决办法
683
查看次数

如何在mapKit框架中使用自定义图标?

我正在使用MapKit框架在我的应用程序上加载谷歌地图,我在地图上放置4个"模拟"的地方,如下所示:

- (void)viewDidLoad {

[super viewDidLoad];

mapView.delegate = self;

mapView.showsUserLocation = YES;

MKUserLocation *userLocation = mapView.userLocation;

MKCoordinateRegion region =
MKCoordinateRegionMakeWithDistance (userLocation.location.coordinate,500,500);
[mapView setRegion:region animated:NO];

//Simulated annotations on the map
CLLocationCoordinate2D poi1Coord , poi2Coord , poi3Coord , poi4Coord;
//poi1 coordinates
poi1Coord.latitude = 37.78754;
poi1Coord.longitude = -122.40718;
//poi2 coordinates
poi2Coord.latitude = 37.78615;
poi2Coord.longitude = -122.41040;
//poi3 coordinates
poi3Coord.latitude = 37.78472;
poi3Coord.longitude = -122.40516;
//poi4 coordinates
poi4Coord.latitude = 37.78866;
poi4Coord.longitude = -122.40623;

MKPointAnnotation *poi1 = [[MKPointAnnotation alloc] init];
MKPointAnnotation *poi2 = [[MKPointAnnotation alloc] …
Run Code Online (Sandbox Code Playgroud)

mapkit ios

8
推荐指数
1
解决办法
1万
查看次数

如何从iPhone应用程序启动另一个应用程序

我在我的iPhone应用程序中处理地图应用程序.

我有一个按钮go.

当用户在此方法中单击此按钮时,我想检查用户是否已waze在其iphone上安装了该应用程序.如果是,则导航到waze应用程序,否则打开iPhone的默认地图应用程序.

iphone objective-c mapkit ios

8
推荐指数
2
解决办法
2万
查看次数

平滑调整MKCircle的大小

在调整NSSlider时,如何在UIMapView上平滑调整MKCircleView的大小?苹果已经成功地做到这一点在查找好友创建地理围栏时,应用程序(http://reviewznow.com/wp-content/uploads/2013/03/find-my-friends-location-alerts-01.jpg),所以我想这在某种程度上是可能的.到目前为止,我已经尝试了以下解决方案,但结果非常"闪烁":

第一次尝试

我添加了一个具有更新半径的新MKCircleView,并在移除滑块更改值后立即移除(如此处建议MKOverlay不能平滑地调整大小).我也尝试过另一种方法:首先删除叠加层,然后添加一个新叠加层,但使用相同的"flickery"结果.

- (void)sliderChanged:(UISlider*)sender
{
    double radius = (sender.value * 100);
    [self addCircleWithRadius:radius];
    [mapView removeOverlays:[self.mapView.overlays firstObject]];
}
Run Code Online (Sandbox Code Playgroud)

第二次尝试

在链接的SO答案中,他建议NSOperation可用于"帮助您更快地创建MKCircle对象",从而在幻灯片更改值时使用上述添加/删除叠加层的方法使调整大小更加平滑.我做了一个实现,每当滑块改变时我就开始一个新的线程.在每个线程中,我删除所有旧的叠加层并添加一个新的叠加层.也许他还有其他一些实现方式,因为我这样做的方式在更改滑块时仍然会出现相同的闪烁.

- (void)sliderChanged:(UISlider*)sender
{
     NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self
                                                                             selector:@selector(updateOverlayWithScale:)
                                                                               object:[NSNumber numberWithFloat:sender.scale]];
     [self.queue addOperation:operation];
}
Run Code Online (Sandbox Code Playgroud)

每个线程运行的方法:

- (void)updateOverlayWithScale:(NSNumber *)scale
{
    MKCircle *circle = [MKCircle circleWithCenterCoordinate:self.currentMapPin.coordinate
                                                     radius:100*[scale floatValue]];


    [self.mapView performSelectorOnMainThread:@selector(removeOverlays:) withObject:self.mapView.overlays waitUntilDone:NO];
    [self.mapView performSelectorOnMainThread:@selector(addOverlay:) withObject:circle waitUntilDone:NO];
}
Run Code Online (Sandbox Code Playgroud)

第三次尝试

我还尝试实现我自己的MKOverlayView子类,它根据scale属性绘制自己.每当滑块改变时,我调用setNeedsDisplay并让它自己重绘,但我得到相同的闪烁.

- (void)sliderChanged:(UISlider*)sender
{
     self.currentOverlayView.scale = sender.scale
     [self.currentOverlayView setNeedsDisplay];
}
Run Code Online (Sandbox Code Playgroud)

而在我的自定义重叠视图我实现drawMapRect:zoomScale:inContext的:(CGContextRef)背景下这样的

- (void)drawMapRect:(MKMapRect)mapRect
          zoomScale:(MKZoomScale)zoomScale
          inContext:(CGContextRef)context
{
     double …
Run Code Online (Sandbox Code Playgroud)

objective-c mapkit mkmapview ios mkoverlay

8
推荐指数
1
解决办法
2715
查看次数

如何在GMSMapView上设置自定义注释标记(围绕点的动画环)

使用谷歌地图iOS SDK我已经实现了mapView,我已经创建了如下标记

// Creates a marker in the center of the map.
GMSMarker *marker = [[GMSMarker alloc] init];
marker.position = CLLocationCoordinate2DMake(-33.86, 151.20);
marker.title = @"Sydney";
marker.snippet = @"Australia";

marker.icon = [UIImage imageNamed:@"point1.png"]; 

marker.map = mapView_;
Run Code Online (Sandbox Code Playgroud)

但我需要显示动画图像,即要显示的一些图像序列,一个点周围的动画环,而不是原始的GMSMarker

图像序列是point1.png point2.png point3.png point4.png point5.png

任何人都可以帮助我实现这一目标

google-maps objective-c mapkit ios google-maps-sdk-ios

8
推荐指数
1
解决办法
1万
查看次数

如何从地址字符串中获取lat和long坐标

我有一个MKMapView,有一个UISearchBar在上面,我希望用户能够键入一个地址,并找到该地址并在其上放置一个图钉.我不知道的是如何将地址字符串转换为经度和纬度,所以我可以创建一个CLLocation对象.有谁知道我怎么做到这一点?

mapkit cllocation cllocationcoordinate2d

8
推荐指数
1
解决办法
1万
查看次数

使用MKOverlayRenderer在MKMapView覆盖中不起作用的动画gif

我试图在叠加中显示动画gif MKMapView.使用MKOverlayRenderer.创建叠加层.动画中的iOS 7的GIF,我使用的是UIImage+animatedGIF贴类别这里 GitHub上.

使用类别,动画gif的图像在叠加中显示得很好; 但是,gif没有动画.我没有问题使用类别来动画gif中的gif,UIImageView但它似乎无法在地图视图叠加中正常工作.

如何使用此类别将动画gif放置在地图视图叠加层中?

要么...

有没有办法UIImageView在覆盖中放置一个可以通过设置UIImageView动画gif 来解决我的问题?

我的叠加渲染器子类如下:

MapOverlayRenderer.h

#import <MapKit/MapKit.h>

@interface MapOverlayRenderer : MKOverlayRenderer
- (instancetype)initWithOverlay:(id<MKOverlay>)overlay overlayImage:(UIImage *)overlayImage;
@end
Run Code Online (Sandbox Code Playgroud)

MapOverlayRenderer.m

#import "MapOverlayRenderer.h"

@interface MapOverlayRenderer ()
@property (strong,nonatomic) UIImage *image;
@end

@implementation MapOverlayRenderer

- (instancetype)initWithOverlay:(id<MKOverlay>)overlay overlayImage:(UIImage *)overlayImage {

    self = [super initWithOverlay:overlay];

    if (self) {
        _image = overlayImage;
    }

    return self;
}

- (void)drawMapRect:(MKMapRect)mapRect zoomScale:(MKZoomScale)zoomScale inContext:(CGContextRef)context {

    CGImageRef imageReference = self.image.CGImage;

    MKMapRect theMapRect = [self.overlay …
Run Code Online (Sandbox Code Playgroud)

objective-c uiimageview mapkit mkoverlay ios7

8
推荐指数
1
解决办法
3408
查看次数

MKPolylineView initWithPolyLine:在iOS 7中已弃用

我收到以下错误:: initWithPolyline不推荐使用:首先在iOS 7.0中弃用

MKPolylineView *lineView = [[MKPolylineView alloc] 
       initWithPolyline:overlay];
Run Code Online (Sandbox Code Playgroud)

替代方法的替代方法是什么?

deprecated mapkit mkmapview ios mkpolyline

8
推荐指数
2
解决办法
3786
查看次数

向地图添加多个注释但是全部显示一些相同的数据

更新2:

这是映射中的现有代码,但它就像注释使用引脚完全无序.一次引脚为绿色,下次运行时,相同的引脚为红色.断开来自哪里?

-(void) viewWillAppear:(BOOL)animated {
    self.annotationArray = [[NSMutableArray alloc] init];

CLLocationCoordinate2D coord = {.latitude =  15.8700320, .longitude =  100.9925410};
MKCoordinateSpan span = {.latitudeDelta =  3, .longitudeDelta =  3};
MKCoordinateRegion region = {coord, span};
[mapViewUI setRegion:region];
    PFQuery *query = [PFQuery queryWithClassName:@"Share"];
    [query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
        if (!error) {
                       self.mapViewData = objects;
                        for (int i=0;i<[objects count];i++)
            {
                // Question * q = [[Question alloc]init];

                PFObject * obj = [self.mapViewData objectAtIndex:i];
                NSLog(@"%@", obj);
                self.theObject = obj;

                NSString *string = obj[@"WhereAt"];


                NSArray …
Run Code Online (Sandbox Code Playgroud)

mapkit mkmapview mkannotation mkannotationview ios

8
推荐指数
1
解决办法
217
查看次数

Xcode - 调试视图层次结构

我正在尝试调试我的应用程序的视图层次结构,并在Xcode窗口的左侧窗格中显示一个小紫色方块(参见屏幕截图).

知道那个问题可能是什么吗?

Xcode  - 调试视图层次结构

debugging xcode uikit mapkit swift

8
推荐指数
1
解决办法
1791
查看次数