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

Mockup & CodeGen, iPhone & iPad
($9.99)

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

Manu
($0.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 05-13-2009, 12:50 AM   #1 (permalink)
New Member
 
Join Date: May 2009
Posts: 2
Question Cllocation manager with browser app

I am a complete newbi to objective c and iphone sdk and learning some great stuff with new obstacles

ok my problem is i am trying to create a browser app which shows the current location as its html content but i am not getting the location

I was able to get the browser app working from this simple and great tutorial

now i am modifying the code so the html code displays the latitude and longitude

my app is showing 0.0000 for both latitude and longitude i dont know why i am not getting any current location

myGPSBrowser.m
Code:
#import "myGPSBrowserAppDelegate.h"


@implementation myGPSBrowserAppDelegate

@synthesize window;



- (void)applicationDidFinishLaunching:(UIApplication *)application {   
	
		//  initializing the location manager
	
	
	CLLocationManager *locationManager = [[CLLocationManager alloc] init];
	
    locationManager.delegate = self;
   // locationManager.distanceFilter = 1000;  // 1 kilometer
    locationManager.desiredAccuracy = kCLLocationAccuracyBest;
    [locationManager startUpdatingLocation];
	
	
	
	NSDate* eventDate = locationManager.location.timestamp;
	NSTimeInterval howRecent;
	
	// if the location as nt got in last 5 sec then keep trying to get the location
	do{
		
		 howRecent = [eventDate timeIntervalSinceNow];
		
	}
	while(abs(howRecent) > 5.0);
	
	//stop the location manager
	
	[locationManager stopUpdatingLocation];
	
	//get the latitude and longitude

	float mylat= locationManager.location.coordinate.latitude+0.0;
	float mylon= locationManager.location.coordinate.latitude+0.0;
	
	
	
	//create the html for the browser
	
	NSString *HTMLData = [NSString stringWithFormat: @"latitude - %f longitude - %f  at   %f",mylat, mylon, howRecent];

	
	[webView loadHTMLString:HTMLData baseURL:nil];
	
	
	
    // Override point for customization after application launch
    [window makeKeyAndVisible];
}


- (void)dealloc {
	
    [window release];
    [super dealloc];
}


@end
and here is my myGPSBrowser.h
Code:
#import <UIKit/UIKit.h>


@interface myGPSBrowserAppDelegate : NSObject <UIApplicationDelegate, CLLocationManagerDelegate>{
    UIWindow *window;
	
	

	IBOutlet UIWebView *webView;
	
}
@property (nonatomic, retain) IBOutlet UIWindow *window;

//@property(assign, nonatomic) id<CLLocationManagerDelegate> delegate

@end





/*@interface MyLocationGetter : UIViewController<CLLocationManagerDelegate>
{

//	NSString *str;

}
//@property (nonatomic, retain) NSString *str;
//@property   (nonatomic, retain) NSString *locationManager;


@end */
it looks very simple and should work i dont know why it is not working
lionkingden is offline   Reply With Quote
Reply

Bookmarks

Tags
browser, cllocationmanager, gps

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
» Stats
Members: 158,884
Threads: 89,229
Posts: 380,763
Top Poster: BrianSlick (7,129)
Welcome to our newest member, karlam963
Powered by vBadvanced CMPS v3.1.0

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