I am new of xcode, I am writing about a MAPVIEW, which shown the shop location and the user current location.
However I find out that I have to do a 20 shops list , each shop have 1 mapVIEW. I have a problem that then I have to add 20 .h &.m and 20 XIB to finish the 20 shops list.
I don't know whether I can pass the Parameter (p1.latitude=22.327202; p1.longitude = 114.163474 to the LocationManager function, so I don't have to repeat it 20 times.
Please help. Thanks all
However I find out that I have to do a 20 shops list , each shop have 1 mapVIEW. I have a problem that then I have to add 20 .h &.m and 20 XIB to finish the 20 shops list.
I don't know whether I can pass the Parameter (p1.latitude=22.327202; p1.longitude = 114.163474 to the LocationManager function, so I don't have to repeat it 20 times.
Please help. Thanks all
Code:
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation {
loc = [newLocation coordinate];
// CLLocationCoordinate2D p1;
MKCoordinateSpan span;
span.latitudeDelta = 0.008;
span.longitudeDelta = 0.008;
//region.span = span;
//region.center = loc;
//region.center = loc;
p1.latitude=22.327202;
p1.longitude = 114.163474;
MKCoordinateRegion region = MKCoordinateRegionMake(p1, span);
[map setRegion:region animated:YES];
[map regionThatFits:region];
poi= [[POI alloc] initWithCoordinate:loc];
poi1=[[POI alloc] initWithCoordinate:p1];
poi1.title=@"大南街173號";
poi1.subtitle=@"聯昌皮號";
[map addAnnotation:poi1];
[poi1 release];
poi.title=@"CURRENT LOCATION";
[map addAnnotation:poi];
map.showsUserLocation=YES;
[poi release];
}
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation {
loc = [newLocation coordinate];
// CLLocationCoordinate2D p1;
MKCoordinateSpan span;
span.latitudeDelta = 0.008;
span.longitudeDelta = 0.008;
//region.span = span;
//region.center = loc;
//region.center = loc;
p1.latitude=22.327202;
p1.longitude = 114.163474;
MKCoordinateRegion region = MKCoordinateRegionMake(p1, span);
[map setRegion:region animated:YES];
[map regionThatFits:region];
poi= [[POI alloc] initWithCoordinate:loc];
poi1=[[POI alloc] initWithCoordinate:p1];
poi1.title=@"SHOP NO 173";
[map addAnnotation:poi1];
[poi1 release];
poi.title=@"CURRENT LOCATION";
[map addAnnotation:poi];
map.showsUserLocation=YES;
[poi release];
}
Last edited by a moderator: