/**
* according to the specified coordinate points to generate a polyline
*@param coords Specifies an array of latitude and longitude coordinate points
*@param count number of coordinate points
*@returnThe newly generated polyline object
*/
-
(BMKPolyline)polylineWithCoordinates:(CLLocationCoordinate2D)coords count:(NSUInteger)count;
for (NSInteger index = 0; index < array.count; Index plus)
//Generate polylines
BMKPolyline* polyline = [BMKPolyline polylineWithCoordinates:coors count:2];
[_mapView addOverlay:polyline];
bracket
/**
* Generate corresponding View according to overlay
* @ paramamView mapview
*@param overlay Specified overlay
*@returnThe resulting overlay View
*/
(BMKOverlayView)mapView:(BMKMapView)mapView viewForOverlay:(id <BMKOverlay>)overlay;
//proxy method.
-
(BMKOverlayView)mapView:(BMKMapView)map viewForOverlay:(id<BMKOverlay>)overlay
bracket
if ([overlay isKindOfClass:[BMKPolyline class]]) {//Create the polyline view I want MaintenanceBMKPolylineView* polylineView = [[MaintenanceBMKPolylineView alloc] initWithOverlay:overlay]; polylineView.fillColor = [[UIColor cyanColor] colorWithAlphaComponent:1]; polylineView.strokeColor = [[UIColor blueColor] colorWithAlphaComponent:0.7]; polylineView.lineWidth = 5.0; //What I need is that this Array corresponds to data. polylineView.infoArray = [[NSMutableArray alloc] initWithObjects:_maintenancePolylineViewArray[_maintenancePolylineViewIndex-1], nil]; return polylineView; bracket
bracket
@interfaceMaintenanceBMKPolylineView : BMKPolylineView
bracket
bracket
@property (nonatomic , strong) NSMutableArray *infoArray; //Store information of line segments
@end
@implementation MaintenanceBMKPolylineView
@end
Question:
Count if = 10;
for (NSInteger index = 0; index < array.count; Index plus)
//Record the polyline data with an array.
[_maintenancePolylineViewInfoArray addObject:dic];
//Generate polylines
BMKPolyline* polyline = [BMKPolyline polylineWithCoordinates:coors count:2];
[_mapView addOverlay:polyline];
bracket
Now the loop calls 10 times to create a polyline.
If the currently created polyline 0 is outside the mobile phone screen due to longitude and latitude. Then the user will only call after moving the screen
(BMKOverlayView)mapView:(BMKMapView)mapView viewForOverlay:(id <BMKOverlay>)overlay; Method to generate the corresponding polylineView. Draw that line segment.
In the loop, I recorded the contents of 10 polylines with _ maintencepolylineviewinfoarray.
_maintenancePolylineViewInfoArray{A,B,C,D,E…};
Excuse me, how can I make the values in _ maintencepolylineviewinfoarray correspond to every polyline I create? Let each element of _ maintainancelinkviewinfoArray correspond to infoarray of MaintenanceBMKPolylineView in the proxy method.
How did you create your coors? If the number of coors is uncertain, how should you create them?