-(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);
}
Look at that code. I am setting the MKMapview region to the number of distanceFromEastAndWestShyouldBe. The output is:
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
Basically I am setting the map to have 464 m width and the map width is 761 m instead.
Ratio between height and width of MKMapview is 1.43. It doesn't really matter because I use the smaller number for both latitude and longitude.
The code to compute actual difference between east and west in MKMapview is:
-(double)DistanceBetweenWestandEast
{
CLLocationDegrees longitudeDelta=self.theMapView.region.span.longitudeDelta;
double distanceeastwest = longitudeDelta * MetersIn1DegreeofEarth;
return distanceeastwest;
}
with
#define MetersIn1DegreeofEarth 110882.5
defined somewhere else
A work around is simply to divide by 1.6 before changing the mapview region. However, I want to know why it's off in the first place.