2016-09-19 65 views
2

我有一個應用程序中,我顯示在mkmapkit折線這樣的 -在mkmapkit中的多段線上添加箭頭?

self.routeLine = [MKPolyline polylineWithCoordinates:coordinateArray count:4]; 
//[self.mapView setVisibleMapRect:[self.routeLine boundingMapRect]]; //If you want the route to be visible 

[self.mapView addOverlay:self.routeLine]; 

-(MKPolylineRenderer *)mapView:(MKMapView *)mapView viewForOverlay:(id<MKOverlay>)overlay 
{ 
    if(overlay == self.routeLine) 
    { 
     if(nil == self.routeLineView) 
     { 
      self.routeLineView = [[MKPolylineRenderer alloc] initWithPolyline:self.routeLine]; 
      self.routeLineView.fillColor = [UIColor redColor]; 
      self.routeLineView.strokeColor = [UIColor redColor]; 
      self.routeLineView.lineWidth = 2; 

     } 

     return self.routeLineView; 
    } 

    return nil; 
} 

現在我想通過添加一個箭頭,折線顯示這樣

How to draw an arrow on every polyline segment on Google Maps V3

方向

。我搜索了相同的內容,但目前還沒有運氣。任何人都可以指導我如何實現這一目標?

回答

0

我真的建議繪製與MKOverlayPathRenderer箭頭自己,因爲我在這個例子做:

enter image description here

+0

是否有可能像GoogleMap的折線圖標? – hacker

+0

我不知道你想實現什麼,但是MKOverlayPathRenderer的意義在於它只是繪製了一個CGPath。所以如果你能繪製它,你可以在地圖上顯示它。 – matt

+0

我想實現這樣的http://stackoverflow.com/questions/31305497/how-to-draw-an-arrow-on-every-polyline-segment-on-google-maps-v3 – hacker