내가 ... 내가 Mapkit 및 CoreLocation 프레임 워크를 처음 실행하고 아이폰 앱의 새로운 사용자입니다 ...Mapkit ...... 윈도우 기반 프로젝트
내 응용 프로그램 실행 well..but
1) 내가 MAP 부하에 내 현재 위치를 원하지만 내가 시뮬레이터에 내 응용 프로그램을 테스트 할 때 가져 오지 ...
은 (미국 상태 ... 북미)를 선택 할 때마다 ... :(
2) ... 여러 주석에 대해 무엇을합니까? ...? 어느 대리인 메서드를 사용합니까 ...
두 튜토리얼의 코드를 사용합니다 ..... 제게 올바른 일이라고 말해주십시오 ....? 또는 .... 내가 무엇을 사전에
감사합니다 ... 저를 제안 :)
내가 윈도우 기반 프로젝트 사용 ... 내 AppDelegate.m 파일에
....
// this method execute when user type value in textField and click on OK button...
- (IBAction) showAddress {
//Hide the keypad
[addressField resignFirstResponder];
MKCoordinateRegion region;
MKCoordinateSpan span;
span.latitudeDelta=0.2;
span.longitudeDelta=0.2;
//span.latitudeDelta=28.38;
//span.longitudeDelta=77.12;
CLLocationCoordinate2D location = [self addressLocation];
region.span=span;
region.center=location;
if(addAnnotation != nil) {
[mapView removeAnnotation:addAnnotation];
[addAnnotation release];
addAnnotation = nil;
}
addAnnotation = [[AddressAnnotation alloc] initWithCoordinate:location];
[mapView addAnnotation:addAnnotation];
mapView.delegate = self;
[mapView setRegion:region animated:TRUE];
[mapView regionThatFits:region];
//[mapView selectAnnotation:mLodgeAnnotation animated:YES];
}
-(CLLocationCoordinate2D) addressLocation
{
NSString *urlString = [NSString stringWithFormat:@"http://maps.google.com/maps/geo?q=%@&output=csv",
[addressField.text stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
NSLog(@"the url string is %@",urlString);
NSString *locationString = [NSString stringWithContentsOfURL:[NSURL URLWithString:urlString]];
NSLog(@"locationString is %@",locationString);
NSArray *listItems = [locationString componentsSeparatedByString:@","];
NSLog(@"list items are %@",listItems);
double latitude = 0.0;
double longitude = 0.0;
if([listItems count] >= 4 && [[listItems objectAtIndex:0] isEqualToString:@"200"])
{
latitude = [[listItems objectAtIndex:2] doubleValue];
longitude = [[listItems objectAtIndex:3] doubleValue];
}
else {
//Show error
}
CLLocationCoordinate2D location;
location.latitude = latitude;
location.longitude = longitude;
return location;
}
- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation{
MKPinAnnotationView *annView=[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"currentloc"];
annView.pinColor = MKPinAnnotationColorGreen;
annView.animatesDrop=TRUE;
annView.canShowCallout = YES;
annView.calloutOffset = CGPointMake(-5, 5);
return annView;
}
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
[super viewDidLoad];
//mapView.delegate = self;
locationManager = [[CLLocationManager alloc] init];
[locationManager setDelegate:self];
[locationManager setDistanceFilter:kCLDistanceFilterNone];
[locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
[mapView setShowsUserLocation:YES];
}
내 코드에 대한 귀하의 소중한 시간을 주셔서 감사합니다. ... 알고 싶습니다 ... 제 프로그래밍 방식이 옳습니까? 또는 일부 코드를 수정합니까? – GauravBoss
정리가 필요하며 시뮬레이터가 아닌 디바이스에서 테스트해야합니다. 그렇지 않으면 괜찮아 보입니다. –