JSON ファイルからピンを表示しようとしていますが、ピンが表示されません。助けていただければ幸いです。また、ボタンは別の JSON ページを呼び出します。
my code for mapview.m:
- (void)viewDidLoad
{
[super viewDidLoad];
NSURL *url = [NSURL URLWithString:@"https://w1281595.users.ecs.westminster.ac.uk/shops.php"];
NSData *data = [NSData dataWithContentsOfURL:url];
NSError *error;
NSArray *shoparray = [NSJSONSerialization JSONObjectWithData:data
options:0
error:&error];
if (error != nil)
{
}
CLLocationCoordinate2D location;
NSMutableArray *newAnnotations = [NSMutableArray array];
MKPointAnnotation *newAnnotation;
for (NSDictionary *dictionary in shoparray)
{
location.longitude = [dictionary[@"Longitude"] doubleValue];
location.latitude = [dictionary[@"Latitude"] doubleValue];
newAnnotation = [[MKPointAnnotation alloc] init];
newAnnotation.title = dictionary[@"Name"];
newAnnotation.coordinate = location;
}
[self.mapview addAnnotations:newAnnotations];