建立與設定面圖徵
建立與設定面圖徵
面圖徵之建立與設定,包括:地圖上加入面圖徵、設定面圖徵之邊框寬度及顏色等,並可動態修改面之顏色及邊框寬度,設面線圖徵程式範例如下:
- (void)loadView
{
R = 50;
G = 50;
B = 50;
mapView_ = [[TGMapView alloc] initWithFrame:CGRectZero];
self.view = mapView_;
mapView_.viewer = [TGViewerPosition viewerWithLatitude:23.58 longitude:120.95 zoom:1];
TGPolygonOptions *options;
TGMutablePath *path;
options = [TGPolygonOptions options]; //建立TGPolygonOptions物件
path = [TGMutablePath path]; //建立TGMutablePath物件
options.strokeColor = [UIColor colorWithRed:1 green:0.2 blue:0.2 alpha:0.5];
//設定邊框的顏色
options.fillColor = [UIColor colorWithRed:R/100 green:G/100 blue:B/100 alpha:1 ];
//設定填色顏色
options.strokeWidth = 4.f; //設定邊框寬度,單位為Pixel
[path addCoordinate:CLLocationCoordinate2DMake(24.96, 121.22)];
//新增坐標點,坐標要用WGS84
[path addCoordinate:CLLocationCoordinate2DMake(24.49, 121.23)];
[path addCoordinate:CLLocationCoordinate2DMake(23.95, 120.95)];
[path addCoordinate:CLLocationCoordinate2DMake(24.572104,120.563049)];
options.path = path; //設定Polygon的path
Polygon = [mapView_ addPolygonWithOptions:options]; //將Polygon加入地圖
}