你好朋友在我的應用程序中,我在mapview上顯示多個針腳。我有兩個mutablearray第一緯度和第二經度每個陣列有10個值,因爲我示出在我的方法波紋管代碼:在MKMap上顯示多個針腳iPhone
- (void)showAddressAllBusiness {
annotationsarray=[[NSMutableArray alloc] init];
NSLog(@"%d",[listOfLatitude count]);
NSLog(@"%d",[listOfLongitude count]);
NSLog(@"%d",[listOfPlaceName count]);
for (int i =0;i < [listOfLatitude count]; i++) {
MKCoordinateRegion region = { {0.0, 0.0 }, { 0.0, 0.0 } };
region.center.latitude = [[listOfLatitude objectAtIndex:i] doubleValue];
region.center.longitude = [[listOfLongitude objectAtIndex:i] doubleValue];
region.span.longitudeDelta = 0.1f;
region.span.latitudeDelta = 0.1f;
[self.mapViewCityGuide setRegion:region animated:YES];
[self.mapViewCityGuide setZoomEnabled:YES];
addAnnotation = [[AddressAnnotation alloc]init];
addAnnotation.mTitle = [NSString stringWithFormat:@"%@",[listOfPlaceName objectAtIndex:i]];
addAnnotation.coordinate = region.center;
[self.mapViewCityGuide addAnnotation:addAnnotation];
[annotationsarray addObject:addAnnotation];
}
NSLog(@"%d",[self.mapViewCityGuide.annotations count]);
[self centerMap];
}
當我使用的緯度和經度數組值,其是從web服務出現然後 此代碼不能正常工作,我正在調試代碼,然後mapViewCityGuide變爲零或0x0。
如果我使用硬編碼緯度和經度值作爲數組中提到波紋管和調用這個方法那麼它會在地圖上顯示的所有引腳我怎樣才能解決這個問題
listOfPlaceName = [[NSMutableArray alloc] initWithObjects:@"test",@"test",@"test",@"pithempur",@"test",@"test",@"test",@"test", nil];
listOfLatitude = [[NSMutableArray alloc] initWithObjects:@"22.71957",@"23.17930",@"22.96123",@"22.60987",@"22.45260",@"22.55244",@"22.60000",@"22.68330", nil];
listOfLongitude = [[NSMutableArray alloc] initWithObjects:@"75.85773",@"75.78491",@"76.05141",@"75.69644",@"75.94197",@"75.75653",@"75.30000",@"75.61670", nil];
[self showAddressAllBusiness];