i can only show one of them but not together
i am displaying them in viewdidlaod
this is my current location code
Code:
MKCoordinateRegion region =mapView.region;
region.center.latitude = 1.3123;// mapView.userLocation.location.coordinate.latitude;
region.center.longitude = 103.875;//mapView.userLocation.location.coordinate.longitude;
region.span.longitudeDelta = 0.01f;
region.span.latitudeDelta = 0.01f;
[mapView setRegion:region animated:YES];
//[mapView setDelegate:self];
[mapView setShowsUserLocation:YES];
MyAnnotation *ann = [[MyAnnotation alloc] init];
ann.title = @"Wat2Eat";
ann.subtitle = @"Singapore";
ann.coordinate = region.center;
[mapView addAnnotation:ann];
and this is dest code in same methid
Code:
NSUserDefaults *gete = [NSUserDefaults standardUserDefaults];
NSString *myString = [gete stringForKey:@"keyToLookupString"];
//NSLog(@" this output is %@",myString);
NSString *lat;
NSString *lon;
NSString* saddr = [NSString stringWithFormat:@"%f", 1.3123];
NSString* daddr = [NSString stringWithFormat:@"%f", 103.875];
NSLog(@" GEO44 is %@",saddr);
NSString * theAddress = [myString stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
NSString *urlString = [NSString stringWithFormat:@"http://maps.google.com/maps/geo?q=%@&output=csv",
theAddress];
//NSString *urlString = [NSString stringWithFormat:@"http://maps.google.com/maps/geo?q=%g",daddr,saddr];
//NSLog(@" GEO44 is %@",urlString);
NSString *locationString = [[[NSString alloc] initWithContentsOfURL:[NSURL URLWithString:urlString]] autorelease];
NSLog(@" GEO MAP is %@",locationString);
NSArray *listItems = [locationString componentsSeparatedByString:@","];
if([listItems count] >= 4 && [[listItems objectAtIndex:0] isEqualToString:@"200"])
{
MKCoordinateRegion region = { {0.0, 0.0 }, { 0.0, 0.0 } };
region.center.latitude = [[listItems objectAtIndex:2] doubleValue];
region.center.longitude = [[listItems objectAtIndex:3] doubleValue];
region.span.longitudeDelta = 0.01f;
region.span.latitudeDelta = 0.01f;
[mapView setRegion:region animated:YES];
[mapView setDelegate:self];
MyAnnotation *ann = [[MyAnnotation alloc] init];
ann.title = @"Wat2Eat";
ann.subtitle = @"Singapore";
ann.coordinate = region.center;
[mapView addAnnotation:ann];
MyAnnotation *ann1 = [[MyAnnotation alloc] init];
MKCoordinateRegion region1 = { {0.0,0.0 }, { 0.0,0.0 } };
CLLocationCoordinate2D location = mapView.userLocation.coordinate;
//region.span = span;
region1.center = location;
//ann1.coordinate =1.33,103.8;
[mapView addAnnotation:ann1];
NSLog(@" this map is ");
and this i pin
Code:
(MKAnnotationView *)mapView:(MKMapView *)mV viewForAnnotation:(id <MKAnnotation>)annotation
{
NSLog(@"LOCrrrr");
[self updateRouteView];
routeView.hidden = NO;
[routeView setNeedsDisplay];
MKPinAnnotationView *pinView = nil;
if(annotation != mapView.userLocation)
{
static NSString *defaultPinID = @"com.invasivecode.pin";
pinView = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:defaultPinID];
if ( pinView == nil )
pinView = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:defaultPinID] autorelease];
pinView.pinColor = MKPinAnnotationColorGreen;
pinView.canShowCallout = YES;
pinView.animatesDrop = YES;
}
else
{
NSLog(@"nil");
[mapView.userLocation setTitle:@"I am here"];
}
return pinView;
}