地圖與螢幕投影轉換
地圖與螢幕投影轉換
TGProjection類別使用於轉換螢幕上之位置與地圖上之地理坐標,螢幕位置是以螢幕之pixels,以左上角之相對坐標計算,並提供TGTransformation類別進行WGS84與TWD97坐標系統坐標轉換。
- (void)mapView:(TGMapView *)mapView
didTapAtCoordinate:(CLLocationCoordinate2D)coordinate
{
NSString * txt = @"Tap : WGS84 = %f,%f , TWD97 = %f,%f , Screen = %f,%f";
PointD *twd97 = [TGTransformation wgs84ToTWD97:coordinate]; //WGS84坐標系統轉TWD97坐標系統
CGPoint ScreenPt = [mapView_.projection pointForCoordinate:coordinate]; //地圖坐標轉換成螢幕坐標
txt = [NSString stringWithFormat:txt,coordinate.latitude,coordinate.longitude,twd97.X,twd97.Y,ScreenPt.x,ScreenPt.y];
[self setLabelTxt:txt];
NSLog(@"%@",txt);
[self addMarker:coordinate];
}