設定線圖徵

設定線圖徵

線圖徵設定包含地圖上加入線圖徵、設定線之寬度及顏色等,並可動態修改線之顏色及寬度,設定線圖徵程式範例如下:

- (void)loadView

{

R = 50;

G = 50;

B = 50;

 

mapView_ = [[TGMapView alloc] initWithFrame:CGRectZero];

self.view =  mapView_;

 

TGPolylineOptions *options;

TGMutablePath *path;

 

options = [TGPolylineOptions options];  //建立TGPolylineOptions物件

ath = [TGMutablePath path];  //建立TGMutablePath物件

 

options.color = [UIColor colorWithRed:0.5 green:0.5 blue:0.5 alpha:1]; 

//設定顏色

options.width = 4.f;  //設定寬度

[path addCoordinate:CLLocationCoordinate2DMake(25.06654121.53393)]; 

//新增坐標點,坐標要用WGS84

[path addCoordinate:CLLocationCoordinate2DMake(25.06651121.53332)];

[path addCoordinate:CLLocationCoordinate2DMake(25.05963121.53319)];

options.path = path;  //設定Polylinepath

polyline = [mapView_ addPolylineWithOptions:options];  //Polyline加入地圖

 

mapView_.viewer = [TGViewerPosition viewerWithTarget:CLLocationCoordinate2DMake(25.06651,121.53319) zoom:9];

}

 

回到上方