#import
#import
@interface ViewController : UIViewController
@property (strong, nonatomic) IBOutlet MKMapView *MapView;
@property (nonatomic, retain) MKPolyline *routeLine;
@property (nonatomic, retain) MKPolylineView *routeLineView;
@end
vc.m
#import "ViewController.h"
@interface ViewController (){
NSData *alldata;
NSMutableDictionary *data1;
NSMutableArray *RouteLocation;
NSMutableArray *RouteName;
}
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.MapView.delegate=self;
CLLocationCoordinate2D coordinateArray[2];
coordinateArray[0] = CLLocationCoordinate2DMake(17.372140, 78.348945);
coordinateArray[1] = CLLocationCoordinate2DMake(17.359355, 78.354373);
self.routeLine = [MKPolyline polylineWithCoordinates:coordinateArray count:2];
[self.MapView setVisibleMapRect:[self.routeLine boundingMapRect]]; //If you want the route to be visible
[self.MapView addOverlay:self.routeLine];
}
-(MKOverlayRenderer *)mapView:(MKMapView *)mapView
rendererForOverlay:(id)overlay {
MKPolylineRenderer *renderer = [[MKPolylineRenderer alloc] initWithOverlay:overlay];
renderer.strokeColor = [UIColor redColor];
renderer.lineWidth = 5.0;
return renderer;
}
@end;
#import
@interface ViewController : UIViewController
@property (strong, nonatomic) IBOutlet MKMapView *MapView;
@property (nonatomic, retain) MKPolyline *routeLine;
@property (nonatomic, retain) MKPolylineView *routeLineView;
@end
vc.m
#import "ViewController.h"
@interface ViewController (){
NSData *alldata;
NSMutableDictionary *data1;
NSMutableArray *RouteLocation;
NSMutableArray *RouteName;
}
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.MapView.delegate=self;
CLLocationCoordinate2D coordinateArray[2];
coordinateArray[0] = CLLocationCoordinate2DMake(17.372140, 78.348945);
coordinateArray[1] = CLLocationCoordinate2DMake(17.359355, 78.354373);
self.routeLine = [MKPolyline polylineWithCoordinates:coordinateArray count:2];
[self.MapView setVisibleMapRect:[self.routeLine boundingMapRect]]; //If you want the route to be visible
[self.MapView addOverlay:self.routeLine];
}
-(MKOverlayRenderer *)mapView:(MKMapView *)mapView
rendererForOverlay:(id)overlay {
MKPolylineRenderer *renderer = [[MKPolylineRenderer alloc] initWithOverlay:overlay];
renderer.strokeColor = [UIColor redColor];
renderer.lineWidth = 5.0;
return renderer;
}
@end;
Sign up here with your email
ConversionConversion EmoticonEmoticon