メディア事業部EC事業部 AGENCY事業部
メディア事業部ブログ
前のページへは、ブラウザの戻るボタンでお戻りください。
arefin

Current location latitude longitude iPhone app

Add CoreLocation.framework from existing framework

Then import CoreLocation header and write like locationController.h

#import < UIKit/UIKit.h >
#import < CoreLocation/CoreLocation.h >

@interface locationController : UIViewController {

CLLocationManager *locationManager;

}

@property (nonatomic, retain) CLLocationManager *locationManager;

@end

Then go to your locationController.m and write like

#import “locationController.h”

@implementation locationController

@synthesize locationManager;

Then search viewDidLoad and write like

- (void)viewDidLoad { [super viewDidLoad];

// locationManager update as location locationManager = [[CLLocationManager alloc] init]; locationManager.delegate = self; locationManager.desiredAccuracy = kCLLocationAccuracyBest; locationManager.distanceFilter = kCLDistanceFilterNone; [locationManager startUpdatingLocation];

CLLocation *location = [locationManager location];

// Configure the new event with information from the location. CLLocationCoordinate2D coordinate = [location coordinate];

NSString *latitude = [NSString stringWithFormat:@"%f", coordinate.latitude]; NSString *longitude = [NSString stringWithFormat:@"%f", coordinate.longitude];

NSLog(@”dLatitude : %@”, latitude); NSLog(@”dLongitude : %@”,longitude);

}

You can check latitude longitude on your console log. Enjoy….

カテゴリー:iPad, iPhone , 投稿者名:Arefin Khandoker
PAGE TOP
ページトップへ