0
我正在Xcode 5.1中使用mapkit,並試圖在regionDidChangeAnimated中顯示地圖比例尺。我現在不知道要做到這一點。我試圖環顧四周,但沒有成功。有任何想法嗎?在mapkit中顯示地圖比例
編輯:
-(void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated {
CGPoint nePoint = CGPointMake(self.mapView.bounds.origin.x + mapView.bounds.size.width, mapView.bounds.origin.y);
CGPoint swPoint = CGPointMake((self.mapView.bounds.origin.x), (mapView.bounds.origin.y + mapView.bounds.size.height));
CLLocationCoordinate2D neCoord;
neCoord = [self.mapView convertPoint:nePoint toCoordinateFromView:self.mapView];
CLLocationCoordinate2D swCoord;
swCoord = [self.mapView convertPoint:swPoint toCoordinateFromView:self.mapView];
CLLocationDistance distance = [neCoord distanceFromLocation:swCoord];
}
有什麼理由,我到最後一行,CLLocationDistance得到一個錯誤?
distanceFromLocation方法位於CLLocation類中。 neCoord是一個CLLocationCoordinate2D結構體(不是CLLocation)。要從CLLocationCoordinate2D創建CLLocation,請參閱http://stackoverflow.com/questions/2318547/cllocationcoordinate2d-to-cllocation。 – Anna