2016-08-17 5 views
0

MKMapviewの座標をビュー内のcgpointに変換しようとしています。ここでMKMapView - mapView convertCoordinate:toPointToView:返品する

は私がやっているものです:

CGPoint point = [map convertCoordinate:coord toPointToView:self.view]; 
    NSLog(@"lat = %f, lon = %f", coord.latitude, coord.longitude); 
    NSLog(@"x = %f, y = %f", point.x, point.y); 

私は取得しています出力は次のようになります。

lat = 243568961.394369, lon = 165303343.177200 x = nan, y = nan

私はSO上の他の質問を見ていると、これが正しい方法であると思われますそれについて行く。

希望すると助かります。私はちょうど記録されている座標(COORD)は、私が意図している実際の座標ではないことを認識した

編集

。ここで

は、私は、これは座標取得しています方法です:

CLLocationCoordinate2D coord = CLLocationCoordinate2DMake(tileOverlay.mapRect.origin.x, tileOverlay.mapRect.origin.y); 

だから私は、その問題がMKTileOverlayのMKMapRectから座標を取得して、よりあると思います。

答えて

0

問題は、MKMapPoint値を使用してCLLocationCoordinate2Dを作成しようとしていたことです。明らかに、これによって無効な座標が作成されました。ここで私はそれを修正するために何をしたかである:

MKMapPoint mp = MKMapPointMake(tileOverlay.mapRect.origin.x, tileOverlay.mapRect.origin.y); 

    CLLocationCoordinate2D coord = MKCoordinateForMapPoint(mp); 

    CGPoint point = [map convertCoordinate:coord toPointToView:self.view]; 

、すべて

を意図したとおりに動作します