MKMAPView not showing map
I am using follwing code to show image of the given lat lon value but it gives error
NSString*lat=latitude;
NSString*longi=longitude;
mapView = [[MKMapView alloc] initWithFrame:self.view.bounds];
mapView.mapType = MKMapTypeHybrid;mapView.mapType=MKMapTypeHybrid;
double _lat = [lat doubleValue];
double _lng = [longi doubleValue];
CLLocationCoordinate2D coord = (CLLocationCoordinate2D){_lat, _lng};
MKCoordinateSpan span = (MKC开发者_C百科oordinateSpan){0.2, 0.2};
MKCoordinateRegion region = (MKCoordinateRegion){coord, span};
[mapView setRegion:region];
[self.view addSubview:mapView];
Few questions:
NSString*lat=latitude;, what is your latitute, could it be CGFloat or other type?
Could you print the error message that you see?
Have you use the debugger, at which line of code it crashes? I suggest place a breakpoint at the line where: NSString*lat=latitude;
You need to provide more information of the error (if there is anything from the log). "Give and you will receive", thats what my mentor always teach me. Give more information, and you will receive the answer you want.
精彩评论