我正在尝试制作一个具有多个引脚/位置(大约 50-100)的应用程序。哪条路最容易走?我可以有某种数据库来获取我的位置吗?目前我有一个很好用的代码,但它只显示一个位置/引脚。如何在当前代码上添加更多内容?或者正如我之前所说,使用某种数据库是否有其他更简单的方法?
这是代码:SecoundViewController.h:
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
@interface SecondViewController : UIViewController {
MKMapView *mapview;
}
@property (nonatomic, retain) IBOutlet MKMapView *mapview;
-(IBAction)setMap:(id)sender;
-(IBAction)getlocation;
@end
SecondViewController.m:
#import "SecondViewController.h"
#import "NewClass.h"
@interface SecondViewController ()
@end
@implementation SecondViewController
@synthesize mapview;
-(IBAction)getlocation {
mapview.showsUserLocation = YES;
}
-(IBAction)setMap:(id)sender {
switch (((UISegmentedControl *) sender).selectedSegmentIndex) {
case 0:
mapview.mapType = MKMapTypeStandard;
break;
case 1:
mapview.mapType = MKMapTypeSatellite;
break;
case 2:
mapview.mapType = MKMapTypeHybrid;
break;
default:
break;
}
}
-(void)viewDidLoad {
[super viewDidLoad];
[mapview setMapType:MKMapTypeStandard];
[mapview setZoomEnabled:YES];
[mapview setScrollEnabled:YES];
MKCoordinateRegion region = { {0.0, 0.0 }, {0.0, 0.0 } };
region.center.latitude = 56.15881;
region.center.longitude = 13.76454;
region.span.longitudeDelta = 0.01f;
region.span.latitudeDelta = 0.01f;
[mapview setRegion:region animated:YES];
NewClass *ann = [[NewClass alloc] init];
ann.title = @"Harrys Pub & Restaurang";
ann.subtitle = @"Järnvägsgatan 7";
ann.coordinate = region.center;
[mapview addAnnotation:ann];
}
@end