定義地圖圖窗位置

定義地圖圖窗位置

可藉由設定圖窗中心點坐標及縮放層級,或是以一個TGLatLngBounds範圍,定義圖窗的確切位置,並設定圖窗至該位置。定義圖窗位置程式範例將分為兩部分,說明如下。

以圖窗中心點坐標及縮放層級定義圖窗位置:

- (void)loadView

{

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

self.view =  mapView_;              

mapView_.viewer = [TGViewerPosition viewerWithLatitude:23.58 longitude:120.95 zoom:1]; 

//以圖窗中心點坐標、縮放層級定義圖窗畫面初始位置

}

以一個TGLatLngBounds範圍定義圖窗位置:

-(void)BoundsClick

{

//設置TGLatLngBounds物件

TGLatLngBounds *bounds = [[TGLatLngBounds alloc] initWithCoordinate:Marker1.position

andCoordinate:Marker1.position];

bounds = [bounds including:Marker2.position];

bounds = [bounds including:Marker3.position];

TGViewerUpdate *update = [TGViewerUpdate fitBounds:bounds];  //依照TGLatLngBounds的設置於地圖上顯示指定圖窗範圍

[mapView_ moveViewer:update];

}

回到上方