iphone - 如何在iPhone中的mapview中的两个地方之间画线?

标签 iphone mkmapview

- (MKOverlayView *)mapView:(MKMapView *)mapView12 viewForOverlay:(id <MKOverlay>)overlay
{
    MKPolylineView *overlayView = nil;

    if (nil == overlayView) 
    {       
        overlayView = [[[MKPolylineView alloc] initWithOverlay:overlay] autorelease];

        overlayView.strokeColor = [UIColor blueColor];
        overlayView.lineWidth   = 5.0;  
    }

    return overlayView;
}

最佳答案

我已经在mapview上制作了应用程序。所以如果你想获得正确的路径,你必须使用 KMLViewer 或使用 GoogleMaps 。在 google map 中你可以执行此代码

NSString *urlstring=[NSString stringWithFormat:@"http://maps.google.com/?saddr=%f,%f&daddr=

%f,%f",源位置.纬度,源位置.经度,目的地位置.纬度,目的地

ationlocation.longitude];

[[UIApplication sharedApplication]openURL:[NSURL URLWithString:urlstring]];

关于iphone - 如何在iPhone中的mapview中的两个地方之间画线?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10529258/

相关文章:

iphone - iOS 修复 TableView 到底部,如消息应用程序

ios - React Native,应用程序在模拟器上运行,但不能在真实的 iPhone 上运行

ios - didUpdateUserLocation 没有被调用重新加载 View

iphone - MKMapView 重置回世界观 : Rebaked

iPhone:为什么drawRect没有被调用?

objective-c - 我怎样才能在 Objective-C 中的两个类之间有引用?

iphone - 使用 Interface Builder 将 TTImageView 添加到 XIB

ios - 在 MKMapview 执行 SetRegion 动画函数调用时禁用触摸事件

ios - MKMapViewDelegate:替代监听区域更改事件

ios - 显示多个注释,用户位置位于中心