iOS 在百度地图上画线

iOS 在百度地图上画线




- (void)viewDidLoad

{
    [super viewDidLoad];
    
    BMKMapView *mapview = [[BMKMapView alloc] initWithFrame:self.view.bounds];
    mapview.delegate = self;
    self.view = mapview;
    
    BMKGeoCodeSearch *search = [[BMKGeoCodeSearch alloc] init];
    search.delegate = self;
    
    CLLocationCoordinate2D coors[3] = {0};
    coors[0].latitude = 39.9822079562257;
    coors[0].longitude = 116.34177047554547;
    coors[1].latitude = 39.9822079562257;
    coors[1].longitude = 116.36077047554547;
    coors[2].latitude = 39.9622079562257;
    coors[2].longitude = 116.36177047554547;
    
    BMKPolyline *polyLine = [BMKPolyline polylineWithCoordinates:coors count:3];
    [mapview addOverlay:polyLine];
}

- (BMKOverlayView *)mapView:(BMKMapView *)mapView viewForOverlay:(id )overlay
{
    if ([overlay isKindOfClass:[BMKPolyline class]])
    {
        BMKPolylineView *polyLineView = [[BMKPolylineView alloc] initWithOverlay:overlay];
        polyLineView.strokeColor = [[UIColor cyanColor] colorWithAlphaComponent:1];
        polyLineView.lineWidth = 5.0;
        
        return polyLineView;
    }
    return nil;
}

你可能感兴趣的:(iOS—百度地图)