我如何绘制两条不相互连接的线,两条线必须有不同的颜色,两条线有来自四组坐标的点。所以每条线都有自己的一组坐标。使用目标 C iOS 7。
塔二现在不画
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 如何获得线条颜色
//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;
}