2014-10-03 24 views
0

我的計算有點問題。計算mapcenter,以便移動註釋(gps)仍然保持在屏幕上的可見視圖中

我想要的是應用程序的用戶在地圖可見區域的某處放置移動的地圖註記。雖然註釋位置正在改變(GPS單位),但地圖應該移動,但引腳始終保持在屏幕上的該點。

我試圖從this stackoverflow answer

使用效果和

-(CLLocationDistance) calcluateDistance:(CLLocationCoordinate2D)annotationLocation{ 

CLLocation *annotationPosition = [[[CLLocation alloc]initWithLatitude:annotationLocation.latitude longitude:annotationLocation.longitude]autorelease]; 
CLLocation *centrePosition = [[CLLocation alloc]initWithLatitude:self.mapView.centerCoordinate.latitude longitude:self.mapView.centerCoordinate.longitude]; 
CLLocationDistance distance = [centrePosition distanceFromLocation:trackerPosition]; 
return distance; 

}

導致扔成果轉化爲this stackoverflow anser

自己是不是真正的工作。我知道我的解釋是不是superclear所以請問我,如果有不清楚的地方:)

五月感謝

回答

0

一個與你正在使用的方法的問題是,距離不告訴你方向,即40米開外,但其它是40米還是西?這可能是有用的,以你

一個功能是[MapView的convertPoint:annotationPoint toCoordinateFromView:MapView類]

如果相對於地圖視圖在註釋應該留下來,保存這個值,然後用[我們的觀點圖mapView convertPoint:annotationPoint toCoordinateFromView:mapView]來計算地圖視圖中的座標。

希望它有幫助。

相關問題