我正在研究一個iPhone應用程序,我想查找任何地方的經度,緯度和時區的詳細信息。如何找到任何地方的緯度經度和時區?
我怎樣才能一次獲得所有這些細節?
我們可以很容易找到經緯度,但我們怎麼才能得到那個地方的確切時區?
請問有誰能指導我?
謝謝。
我正在研究一個iPhone應用程序,我想查找任何地方的經度,緯度和時區的詳細信息。如何找到任何地方的緯度經度和時區?
我怎樣才能一次獲得所有這些細節?
我們可以很容易找到經緯度,但我們怎麼才能得到那個地方的確切時區?
請問有誰能指導我?
謝謝。
您可以通過使用
NSTimeZone* destinationTimeZone = [NSTimeZone systemTimeZone];
你是從CLLocationManager GET位置,你也來看看Geonames.org
這是一個免費的web服務,讓您從任何設備獲取時區獲取很多來自long/lat的信息
它們還爲GeoNames Webservices庫提供免費(和開源)Java客戶端(其他語言的庫也提供:紅寶石,蟒蛇,perl的,口齒不清......)
這裏的一些信息,你可以從長期獲取/緯度:(complete list of webservices here)
查找最近的地址
查找最近的路口
查找附近的街道
海拔時區
如果你想知道在這種情況下使用api你可以使用這個api bu t在這個api中,首先使用CLLocationManager
類找到你的經緯度,然後放入這個api。
http://ws.geonames.org/timezone?lat=# {}緯度LNG & =#{} LNG
而且讀谷歌文檔的多個API .....
https://developers.google.com/maps/documentation/timezone/
我希望它可以幫助你
它看起來像你想這樣: -
NSString *timeZoneName = [[NSTimeZone localTimeZone] name];
對我而言,返回"Asia/Kolkata"
。
如果您使用的是systemTimeZone
那麼它代表系統(設備)本身使用的時區。 localTimeZone
返回一個對象,該對象表示應用程序的當前默認時區。
使用此API獲取數據並傳遞緯度和長度值。
可以使用CoreLocation得到經度和緯度。
在您希望經緯度的.h類中添加此項。
#import <UIKit/UIKit.h>
#import <CoreLocation/CoreLocation.h>
@interface CoreLocationViewController : UIViewController <CLLocationManagerDelegate> {
CLLocationManager *locationManager;
}
@property (retain, nonatomic) CLLocationManager *locationManager;
@end
而在你的.m文件
#import "CoreLocationViewController.h"
@implementation CoreLocationViewController
@synthesize locationManager;
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
[self setLocationManager:[[CLLocationManager alloc] init]];
[locationManager setDelegate:self];
[locationManager setDistanceFilter:kCLDistanceFilterNone];
[locationManager setDesiredAccuracy:kCLLocationAccuracyHundredMeters];
[locationManager startUpdatingLocation];
}
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
NSLog(@"My Latitude %f",newLocation.coordinate.latitude);
NSLog(@"My Latitude %f",newLocation.coordinate.longitude);
}
和當前時區您可以使用
NSTimeZone* currentTimeZone = [NSTimeZone systemTimeZone];
NSDateFormatter *dateFormatter = [dateFormat setTimeZone:currentTimeZone];
NSDate *rightNow = [NSDate date];
NSString *dateString = [dateFormatter stringFromDate:rightNow];
Z:我想罰款世界上任何地方的時區而不是當前時區。或至少是世界上任何地點的時區名稱。有什麼方法可以找到? – 2013-05-13 07:30:23
老兄當你的應用程序運行時,可以說倫敦,英格蘭,然後它會給這個特定地點的時區。 – 2013-05-13 07:35:23
或者是你想製作一些他們在世界時鐘中使用的時區查找器?像這個http://www.timeanddate.com/time/map/ – 2013-05-13 07:36:41
從CLLocation獲取NSTimeZone:https://github.com/Alterplay/APTimeZones該實用程序的工作原理本地設備上沒有3D派對服務。
或者如果你只想顯示時區名稱'[destinationTimeZone name]' – 2013-05-13 06:38:19
是啊。但我怎樣才能得到世界上任何地方的時區。 – 2013-05-13 06:40:48
好的,如果你有這個用途,那麼你需要使用一些網絡服務。看看這個http://stackoverflow.com/questions/41504/timezone-lookup-from-latitude-longitude – 2013-05-13 06:43:10