互いに接続されていない 2 つの線を描画するにはどうすればよいですか。2 つの線は異なる色にする必要があります。2 つの線には 4 つの座標セットの点があります。したがって、各行には独自の座標セットがあります。Objective C iOS 7 を使用しています。
Tower Two は現在描画を行っていません
if ([deg2 isEqual: @""] ) {
//nil
}else{
//not nil
//Tower Two
//draw line from lat2/long2 to finalLat2/finalLong2
CLLocationCoordinate2D coordinateArray2[2];
coordinateArray2[0] = CLLocationCoordinate2DMake([lat2 doubleValue], [long2 doubleValue]); //tower two
coordinateArray2[1] = CLLocationCoordinate2DMake(finalLat2, finalLong2);
self.routeLine = [MKPolyline polylineWithCoordinates:coordinateArray2 count:2];
}
タワーワンは引き分け
//tower one
// [self.mapview setVisibleMapRect:[self.routeLine boundingMapRect]]; //If you want the route to be visible
//draw line from lat1/long1 to finalLat1/finalLong1
CLLocationCoordinate2D coordinateArray[2];
coordinateArray[0] = CLLocationCoordinate2DMake([lat1 doubleValue], [long1 doubleValue]); //tower one
coordinateArray[1] = CLLocationCoordinate2DMake(finalLat1, finalLong1);
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];
}
タワーワンがラインカラーを取得する方法は次のとおりです
//Tower One Line
-(MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay:(id<MKOverlay>)overlay
{
if(overlay == self.routeLine)
{
if(nil == self.routeLineView)
{
self.routeLineView = [[MKPolylineView alloc] initWithPolyline:self.routeLine];
self.routeLineView.fillColor = [UIColor greenColor];
self.routeLineView.strokeColor = [UIColor greenColor];
self.routeLineView.lineWidth = 5;
}
return self.routeLineView;
}
return nil;
}