注釈が異なる4つ以上の場所とその場所を結ぶルートを含むMKMapViewを表示する必要があります。MKMapView内に複数の場所を表示しようとしましたが、場所をルートに接続する方法を見つけることができません。また、正しい方法で実装したかどうかを確認しようとしています。「CLLocationCoordinate2D」を作成し、同様に4ポイントの緯度と経度を追加しました。MKAnnotationを実装し、場所を返すカスタムオブジェクトを作成しました。
CLLocationCoordinate2D coordinate1 = CLLocationCoordinate2DMake(40.7180583 ,-74.007109);
CLLocationCoordinate2D coordinate2 = CLLocationCoordinate2DMake(40.716355 ,-74.006816);
CLLocationCoordinate2D coordinate3 = CLLocationCoordinate2DMake(40.715281 ,-74.005485);
CLLocationCoordinate2D coordinate4 = CLLocationCoordinate2DMake(40.71559 ,-74.003114);
AnnotationPoints *location1 = [[AnnotationPoints alloc] initWithCoordinate:coordinate1];
AnnotationPoints *location2 = [[AnnotationPoints alloc] initWithCoordinate:coordinate2];
AnnotationPoints *location3 = [[AnnotationPoints alloc] initWithCoordinate:coordinate3];
AnnotationPoints *location4 = [[AnnotationPoints alloc] initWithCoordinate:coordinate4];
NSArray *poiArray = [[NSArray alloc] initWithObjects:location1,location2,location3,location4,nil];
[mapView addAnnotations:poiArray];
//Inside the Annotation Class initWithCoordinate Method is implemented this way:-
-(id)initWithCoordinate:(CLLocationCoordinate2D) c{
coordinate=c;
NSLog(@"%f,%f",c.latitude,c.longitude);
return self;
}
ここでの私の懸念は、すべての場所に注釈ポイントを作成する必要があることです。すべてのポイントを1か所にロードできる代替手段はありますか?そして、ここでのもう1つの難しさは、すべての複数のポイントを接続するルートです。これについて何か助けはありますか?どうもありがとう