ナビゲーションベースのアプリケーションを作成しています。このアプリケーションでは、ユーザーが選択したポイントからルートを描画しています。
私が使用したルートを計算するためGoogle direction API
。ルートを描くために私はこのコードを使用しました
- (void) drawRoute:(NSArray *) path
{
NSInteger numberOfSteps = path.count;
[self.objMapView removeOverlays: self.objMapView.overlays];
CLLocationCoordinate2D coordinates[numberOfSteps];
for (NSInteger index = 0; index < numberOfSteps; index++)
{
CLLocation *location = [path objectAtIndex:index];
CLLocationCoordinate2D coordinate = location.coordinate;
coordinates[index] = coordinate;
}
for( id <MKOverlay> ovr in [self.objMapView overlays])
{
MKPolylineView *polylineView = [[MKPolylineView alloc] initWithPolyline:ovr];
if (polylineView.tag == 22)
{
[self.objMapView removeOverlay:ovr];
}
[polylineView release];
}
MKPolyline *polyLine = [MKPolyline polylineWithCoordinates:coordinates count:numberOfSteps];
[self.objMapView addOverlay:polyLine];
}
問題:〜ルートを描画しているときに、道路にポリラインを描画していないという問題が発生しました。これを説明するために私は画像を添付しました
写真に示されているように、ポリラインは道路上にありません。
使用UICGDirections
したことがありますが、正常に動作しない場合があります。
mapviewを初めて使用するのを手伝ってください。
前もって感謝します