SOMDFLIPS
SOMDFLIPS

Reputation: 1

Collecting map coordinates via using an array then plotting with MKPolyLine

I'm a newbie when it comes to programming IOS devices and I need a little help. I'm trying to create an array that will store GPS coordinates as a drive from point a to point b then I want to plot them on a map using MKPolyLine.. If someone could just give me some pointers I would greatly appreciate it! Thanks!

Upvotes: 0

Views: 858

Answers (1)

Haris Hussain
Haris Hussain

Reputation: 2581

Yes, make an NSMutableArray of location coordinates (lat, long) like this:

[arrayOfDesc addObject:[
                        [CLLocation alloc] initWithLatitude:location.coordinate.latitude longitude:location.coordinate.longitude]];

and then use classes from this source code. use 'NVPolylineAnnotation' and 'NVPolylineAnnotationView' classes. and pass your array through a method:

NVPolylineAnnotation *annotations = [[NVPolylineAnnotation alloc] initWithPoints:arrayOfDesc mapView:_mapView];
[_mapView addAnnotation:annotations];

Its is really simple, you just need to pass the coordinates to the classes, the mentioned classes do the rest :)

Upvotes: 1

Related Questions