Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 07-07-2010, 10:20 PM   #1 (permalink)
Senior Member
 
Join Date: Feb 2010
Location: dallas
Posts: 219
gud4nuthin is on a distinguished road
Default either current location or destinaiton in mapview

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;
}
gud4nuthin is offline   Reply With Quote
Old 07-07-2010, 11:45 PM   #2 (permalink)
Senior Member
 
Join Date: Feb 2010
Location: dallas
Posts: 219
gud4nuthin is on a distinguished road
Default

well its fixed now
setuserlocation=YES

actually earlier also it was working only thing was my current focus was on destination and dest and source wer far form each other
gud4nuthin is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 351
13 members and 338 guests
akacaj, c2matrix, cgokey, esoteric, EXOPTENDAELAX, GHuebner, givensur, HemiMG, Mirotion22, mjnafjke, Pudding, SLIC, Sonuye857
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,652
Threads: 94,115
Posts: 402,887
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Sonuye857
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 10:21 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0