-(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 区域设置为 distanceFromEastAndWestShyouldBe 的数量。输出是:
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
在别处定义
解决方法是在更改地图视图区域之前简单地除以 1.6。但是,我想知道为什么它首先关闭。