tags:

views:

12

answers:

0

i cannt add them together here is the code in viewdidload

///// show current location
//mapView.showsUserLocation = YES;
//mapView.userLocation.location.coordinate.latitude;

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];

//// lat and long paramerets

/// show destination

// getting dic

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 ");


    [mapView setShowsUserLocation:YES]; 


    MyAnnotation *ann = [[MyAnnotation alloc] init];
    ann.title = @"Wat2Eat";
    ann.subtitle = @"Singapore";
    ann.coordinate = region.center;
    [mapView addAnnotation:ann];

}
else 
{
    //statusMessage.text = @"Invalid address";
    //Error
}