-(void) setTheMapViewRegionBasedonCurrentAnchorandDistance
{
//PD([BNUtilitiesQuick MaxDistanceOnSearch]);
//self.theMapView.centerCoordinate = [cachedProperties singleton].currentAnchor.coordinate;
//self.theMapView.region.span.longitudeDelta=[BNUtilitiesQuick MaxDistanceOnSearch]*safetyMarginForMap;
double ratio = self.theMapView.frame.size.height/self.theMapView.frame.size.width;
//double ratio = self.theMapView.visibleMapRect.size.height/self.theMapView.visibleMapRect.size.width;
PD([BNUtilitiesQuick MaxDistanceOnSearch]);
double distanceFromEastAndWestShyouldBe = [BNUtilitiesQuick MaxDistanceOnSearch]*ratioBetweenEastWestToDistanceFilter;
PD(distanceFromEastAndWestShyouldBe);
self.theMapView.region = MKCoordinateRegionMakeWithDistance([cachedProperties singleton].mapCenterLocation.coordinate,distanceFromEastAndWestShyouldBe, distanceFromEastAndWestShyouldBe);
PD(self.DistanceBetweenWestandEast);
PD(ratio);
}
そのコードを見てください。MKMapview 領域を distanceFromEastAndWestShouldBe の数に設定しています。出力は次のとおりです。
2012-08-10 11:30:13.789 BadgerNew[15438:17003] <0x874d0b0 GoogleMap.m:(394)> [BNUtilitiesQuick MaxDistanceOnSearch]: 193.690170
2012-08-10 11:30:13.789 BadgerNew[15438:17003] <0x874d0b0 GoogleMap.m:(396)> distanceFromEastAndWestShyouldBe: 464.856409
2012-08-10 11:30:13.790 BadgerNew[15438:17003] <0x874d0b0 GoogleMap.m:(398)> self.DistanceBetweenWestandEast: 761.369705
2012-08-10 11:30:21.329 BadgerNew[15438:17003] <0x874d0b0 GoogleMap.m:(399)> ratio: 1.437500
基本的に、マップの幅を 464 m に設定し、代わりにマップの幅を 761 m に設定しています。
MKMapview の高さと幅の比率は 1.43 です。緯度と経度の両方に小さい方の数値を使用しているため、特に問題はありません。
MKMapview で東と西の実際の差を計算するコードは次のとおりです。
-(double)DistanceBetweenWestandEast
{
CLLocationDegrees longitudeDelta=self.theMapView.region.span.longitudeDelta;
double distanceeastwest = longitudeDelta * MetersIn1DegreeofEarth;
return distanceeastwest;
}
と
#define MetersIn1DegreeofEarth 110882.5
別の場所で定義
回避策は、mapview 領域を変更する前に 1.6 で除算することです。しかし、そもそもなぜオフになっているのか知りたいです。