0
对于iPad应用程序,我在SplitView上使用左侧的TableView显示餐厅列表。右侧有一个MapView显示这些餐馆的注释。在地图视图中突出显示注释
我想放大到一个注释,并以某种方式突出显示它,当用户点击左侧表中的相关餐厅。
不幸的是我没有得到地图重新加载。
任何建议或想法如何解决这个问题?
这里是我的viewDidLoad
- (void)viewDidLoad {
NSString *docsDir;
NSArray *dirPaths;
dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
docsDir = [dirPaths objectAtIndex:0];
databasePath = [[NSString alloc] initWithString: [docsDir stringByAppendingPathComponent: @"smshipaddec2011.db"]];
const char *dbpath = [databasePath UTF8String];
MapViewAnnotation *newAnnotation;
sqlite3_stmt *statement;
if (sqlite3_open(dbpath, &smshdb2) == SQLITE_OK) {
NSString *querySQL = [NSString stringWithFormat: @"SELECT vmapx, vmapy, vname, vsection FROM SMSHVENUES"];
const char *query_stmt = [querySQL UTF8String];
if (sqlite3_prepare_v2(smshdb2, query_stmt, -1, &statement, NULL) == SQLITE_OK) {
while(sqlite3_step(statement) == SQLITE_ROW) {
double latitude = sqlite3_column_double(statement, 0);
double longitude = sqlite3_column_double(statement, 1);
CLLocationCoordinate2D location;
location.latitude = latitude;
location.longitude = longitude;
newAnnotation = [[MapViewAnnotation alloc] initWithTitle:[[NSString alloc] initWithUTF8String:
(const char *) sqlite3_column_text(statement, 2)] andCoordinate:location];
[mapView addAnnotation:newAnnotation];
[newAnnotation release];
}
sqlite3_finalize(statement);
}
sqlite3_close(smshdb2);
}
mapView.showsUserLocation = YES;
[mapView setMapType:MKMapTypeStandard];
[mapView setZoomEnabled:YES];
[mapView setScrollEnabled:YES];
CLLocation *userLoc = mapView.userLocation.location;
CLLocationCoordinate2D userCoordinate = userLoc.coordinate;
MKCoordinateRegion region = { {0.0, 0.0 }, { 0.0, 0.0 } };
//this is Shanghai:
region.center.latitude = 31.227849 ;
region.center.longitude = 121.473770;
region.span.longitudeDelta = 0.02f;
region.span.latitudeDelta = 0.02f;
[mapView setRegion:region animated:YES];
[super viewDidLoad];
}
现在,当有人点击表格单元格“configureView”被触发,工作正常。但后来我不知道如何移动地图,放大到该注释,也许改变颜色或使其变大。
- (void)configureView {
// animate map
// zoom to annotation
// make it bigger or change colour
}
真的很感谢任何帮助。
谢谢。这工作。 – user1104325