2013年10月23日

座標系変換

MapKitの座標系とUIViewの座標系の相互変換。

MapKitの座標系→UIViewの座標系
CLLocationCoordinate2D coord = CLLocationCoordinate2DMake(latitude, longitude);
CGPoint point = [self.mapView convertCoordinate:coord toPointToView:self.mapView];

// point.x  x軸
// point.y  y軸



UIViewの座標系→MapKitの座標系
CGPoint point = [recognizer locationInView:self.view];
CLLocationCoordinate2D coord = [self.mapView convertPoint: point toCoordinateFromView:self.mapView];

// coord.latitude 緯度
// coord.longitude 経度


参考記事:
http://stackoverflow.com/questions/11252542/cgpoint-to-clllocationcoordinate2d-convertpoint-tocoordinatefromview-not-worki


ラベル:IOS Mac apple iPAD iPhone
posted by mobileDeveloper at 22:27 | Comment(0) | TrackBack(0) | MapKit | このブログの読者になる | 更新情報をチェックする
この記事へのコメント
コメントを書く
お名前:

メールアドレス:

ホームページアドレス:

コメント:

認証コード: [必須入力]


※画像の中の文字を半角で入力してください。
※ブログオーナーが承認したコメントのみ表示されます。

この記事へのトラックバック