标签: mapkit

Mapkit引脚颜色没有变化

我正在做以下事情,总是得到绿色的针脚:

pin.pinColor = MKPinAnnotationColorRed;
        [self.mapView addAnnotation:pin];
        [pin release];
Run Code Online (Sandbox Code Playgroud)

pin的类型为"NSObject".所有引脚都是绿色的.我应该采用不同的方式吗?

iphone cocoa-touch mapkit

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

Mapkit,如何检测已加载的注释

当引脚完成它的放置动画时,我希望弹出注释标注.目前我可以使用以下方法模拟它:

- (void)showCallOut {
    [myMapView selectAnnotation:[myMapView.annotations objectAtIndex:0] animated:YES];
}
Run Code Online (Sandbox Code Playgroud)

在我viewDidLoad的地方创建了我的注释

    [myMapView addAnnotation:annotation];
Run Code Online (Sandbox Code Playgroud)

问题是你之后根本无法[self showCallOut];调用,因为在运行时它会在MapKit"确认"注释掉落之前做出响应.我需要创建一个延迟(想要避免这种情况)或者找到正确的方法来检测注释何时就位,然后运行该showCallOut方法.

谢谢你的帮助!

感谢下面的aBitObvious提供解决方案:

- (void)mapView:(MKMapView *)mapView didAddAnnotationViews:(NSArray *)views {
    [self performSelector:@selector(showCallOut) withObject:nil afterDelay:1];
}
Run Code Online (Sandbox Code Playgroud)

iphone cocoa-touch mapkit

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

如何在两个位置之间绘制路线并使用MapKit绘制主要点?

我正在使用MapKit api获取地图上的当前位置,并在两个位置指针之间绘制路线.我还希望获得其路线之间的所有主要站点.我使用下面的函数来获取两个位置之间的路由

- (NSArray*)getRoutePointFrom:(MyLocation*)origin to:(MyLocation*)destination
{
 NSString* saddr = [NSString stringWithFormat:@"%f,%f", origin.coordinate.latitude, origin.coordinate.longitude];
 NSString* daddr = [NSString stringWithFormat:@"%f,%f", destination.coordinate.latitude, destination.coordinate.longitude];


 NSURL *url=[NSURL URLWithString:[NSString stringWithFormat:@"http://maps.googleapis.com/maps/api/directions/json?origin=%@&destination=%@&sensor=false&avoid=highways&mode=driving",saddr,daddr]];

 NSError *error=nil;

 NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init] ;

 [request setURL:url];
 [request setHTTPMethod:@"POST"];

  NSURLResponse *response = nil;

  NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error: &error];

  NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];

 SBJsonParser *json=[[SBJsonParser alloc] init];

 NSDictionary *dic=[json objectWithString:responseString error:nil];

 NSDictionary *nextdic=[dic valueForKey:@"routes"];
 NSDictionary *legdic=[nextdic valueForKey:@"legs"];
 NSDictionary *stepdic=[legdic valueForKey:@"steps"];

 NSArray *array=[[NSArray alloc] initWithArray:[[stepdic valueForKey:@"polyline"] valueForKey:@"points"]];  


 NSString …
Run Code Online (Sandbox Code Playgroud)

iphone objective-c mapkit ios5

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

如何在ios 6中的地图上绘制路线?

我想在地图上显示地图和绘制路线.我的应用程序支持ios 4 plus.那么我应该如何使用地图来处理ios 6以及之前的工作.另外我想知道sholud我在我的应用程序中使用自定义mapview来显示地图和路线,或者我应该使用

[[UIApplication sharedApplication] openURL:]
Run Code Online (Sandbox Code Playgroud)

我从来没有用过MapKits.所以请提供任何教程.如果有任何可以使用的rd方库,请告诉我.

iphone maproute mapkit ios ios6-maps

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

在MKPointAnnotation上注册触摸事件

我想设置一个MKPointAnnotation,当它被点击时,我可以调用另一个功能.反正有没有添加手势识别器或类似的东西?

mapkit swift

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

如何使用MapKit快速旋转自定义userLocationAnnotationView图像?

我正在尝试找到一种使用MapKit在地图上显示用户方向的方法。MapKit的本机方法总是旋转整个地图。由于用户位置也是MKAnnotationView,因此我决定创建一个特定的类来覆盖它并使用特定的图像(带有箭头)。

class UserLocationAnnotationView: MKAnnotationView {

override init(frame: CGRect) {
    super.init(frame: frame)
}

override init(annotation: MKAnnotation!, reuseIdentifier: String!) {

    super.init(annotation: annotation, reuseIdentifier: reuseIdentifier)

    var frame = self.frame
    frame.size = CGSizeMake(130, 130)
    self.frame = frame
    self.backgroundColor = UIColor.clearColor()
    self.centerOffset = CGPointMake(-30, -50)

}

required init(coder aDecoder: NSCoder) {
    super.init(coder: aDecoder)!
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
*/
override func drawRect(rect: CGRect) {
    // Drawing code
    UIImage(named: "userLocation.png")?.drawInRect(CGRectMake(65, 65, …
Run Code Online (Sandbox Code Playgroud)

direction mapkit mkannotationview ios swift

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

如何设置自定义距离滤镜,在Swift中可以吗?

我是新手Swift,我尝试了这个

使用MKMapView时如何设置精度和距离过滤器

不知道为什么此代码不起作用:

//start  mehtod out of scope
lazy var locationManager: CLLocationManager! = {
    let locationManager = CLLocationManager()


    //configeration for  user location access
    //The delegate object to receive update events.
    locationManager.delegate = self
    //The receiver does its best to achieve the requested accuracy
    //locationManager.desiredAccuracy = kCLLocationAccuracyBest
     self.locationManager.distanceFilter = 10.0
    //Requests permission to use location services while the app is in the foreground
    locationManager.requestWhenInUseAuthorization()
    //allow update notification when apps stay on background
    locationManager.allowsBackgroundLocationUpdates = true

    return locationManager
}() 
Run Code Online (Sandbox Code Playgroud)

当我设置时它工作正常: …

mapkit ios swift

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

如何从MKLocalSearchCompletion中提取国家和城市?

我从MKLocalSearchCompleter收到MKLocalSearchCompletion项目给它的委托.每个MKLocalSearchCompletion都包含一个标题和一个副标题,副标题是一个地址.我需要从地址中提取一个城市和一个国家.请帮忙!

mapkit ios

3
推荐指数
2
解决办法
1507
查看次数

MKMarkerAnnotationView集群颜色

我一直在尝试新的iOS 11 MKMarkerAnnotationView,最后聚类就像魅力一样.但问题是群集的颜色错误,如图所示.我该怎么控制呢?簇颜色错误

mapkit mapkitannotation ios11

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

“ MKMapRectIsNull”已由属性“ MKMapRect.isNull”替换

因此,在更新到Xcode 10和Swift 4.2时,我当然必须在项目中进行很多更改以更新语法。除了一个问题,我能够解决所有问题。我收到一条错误消息:'MKMapRectIsNull'已由属性'MKMapRect.isNull'代替。我也试图替换明显的事情MKMapRectIsNullMKMapRect.isNull,但其产生的另一个错误,说:实例成员“的isNull”不能在类型“MKMapRect”使用。这里是一些更多的上下文:

var zoomRect = MKMapRect.null
    for annotation in map.annotations {
        let annotationPoint = MKMapPoint(annotation.coordinate)
        let pointRect = MKMapRect(x: annotationPoint.x, y: annotationPoint.y, width: 0, height: 0)
        if (MKMapRect.isNull(zoomRect)) {
            zoomRect = pointRect
        } else {
            zoomRect = zoomRect.union(pointRect)
        }
    }
    map.setVisibleMapRect(zoomRect, edgePadding: UIEdgeInsets(top: 40, left: 40, bottom: 40, right: 40), animated: true)
Run Code Online (Sandbox Code Playgroud)

任何想法/帮助将不胜感激。

xcode mapkit mkmapview swift swift4.2

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