㈠ iOS 高德地圖地理編碼
框架:MapKit.framework,CoreLocation.framework 兩個足矣
添加地圖就不說了,
用CoreLocation.framework裡面的CLGeocoder類,進行轉換
可用的函數下面三個:
- (void)geocodeAddressDictionary:(NSDictionary *)addressDictionary completionHandler:(CLGeocodeCompletionHandler)completionHandler;
- (void)geocodeAddressString:(NSString *)addressString completionHandler:(CLGeocodeCompletionHandler)completionHandler;
- (void)geocodeAddressString:(NSString *)addressString inRegion:(CLRegion *)region completionHandler:(CLGeocodeCompletionHandler)completionHandler;
(這三個函數的用法就不說了,一搜一堆)
可以得到地理位置,然後地圖設置一下center或者region就OK了
㈡ 什麼是地理數據編碼,它有什麼作用
地理編碼是為識別點、線、面的位置和屬性而設置的編碼,它將全部實體按照預先擬定的分類系統,選擇最適宜的量化方法,按實體的屬性特徵和集合坐標的數據結構記錄在計算機的儲存設備上。
正向地理編碼提供的專業和多樣化的引擎以及豐富的資料庫數據使得服務應用非常廣泛,在資產管理、規劃分析、供應物流管理和移動端輸入等方面為用戶創造無限的商業價值。
(2)ios反地理編碼能獲取哪些信息擴展閱讀:
正向服務:
1、反向地理編碼服務
反向地理編碼服務實現了將地球表面的地址坐標轉換為標准地址的過程,反向地理編碼提供了坐標定位引擎,幫助用戶通過地面某個地物的坐標值來反向查詢得到該地物所在的行政區劃、所處街道、以及最匹配的標准地址信息。通過豐富的標准地址庫中的數據,可幫助用戶在進行移動端查詢、商業分析、規劃分析等領域創造無限價值。
2、向量式地理編碼
向量式地理編碼(vector geocoding)指使用坐標參考系統去定義點、線、面特徵的位置。 向量化(vectorization):指將網格式資料轉換為向量形式的過程。
3、網格式地理編碼
網格式地理編碼(raster geocoding)指使用建立於矩陣或方格的座標系統來標定位置,這樣的位置資料包含欄與列,稱為圖元(pixel)。 柵格化(rasterization)指將向量式資料轉換為網格形式的過程。
㈢ iPhone6的12123地理反編碼失敗怎麼辦
解決辦法:
1、 如果請求不成功或在傳輸層中止,則根據 值指定的方式,請求將被取消。
2、如果請求不成功,則引發LocatorException,並帶有一個錯誤代碼,指明請求不成功的原因。
3、可以中斷設備應用程序可以使用定位器類,以便一次只發出一個請求。
蘋果有自己獨立的定位,不允許別人來掌控。
(1)地理編碼:把地理名字轉為地理位置。
(2)作用:把地理名字轉為經緯度。
(3)反編碼:把位置信息轉換成文字內容。
(4)作用:可以點擊地圖上的某個位置 來獲得該位置的文字描述。
(5)用漢字表示:漢字必須寫在度數的前面如:北緯40°、南緯25°、東經10°、西經35°
(6)用英文字母表示:字母必須寫在度數的後面(N表示北緯、S表示南緯、E表示東經、W表示西經。這四個字母其實就是英文單詞中東、西、南、北四個方向單詞的頭一個字母)如:北緯40°=40°N、南緯25°=25°S、東經10°=10°E、西經35°=35°W。
(7)如果問經度和經度坐標,哪個寫在前,哪個寫在後,就好像數學中直角坐標系中的X值、Y值誰在前、誰在後的問題。至於地理經緯度的前後,沒有硬性規定,關鍵是平時的書寫習慣,順序顛倒了,也不會算你錯。(在地理專業中,多數情況下是先寫經度,後寫緯度)。
參考鏈接:
IPone 6網路
參考圖片:
㈣ android 反地理編碼問題
剛好之前的項目用到這個問題了,貼下之前的代碼,希望能幫助到您,謝謝。
這個方法就是根據經緯度得到地理信息的方法。
GeoCoder geocoder = GeoCoder.newInstance();
geocoder.reverseGeoCode(new
ReverseGeoCodeOption().location(mCenterLatLng));
geocoder.setOnGetGeoCodeResultListener(new OnGetGeoCoderResultListener()
{
@Override
public void
onGetGeoCodeResult(GeoCodeResult geoCodeResult) {
//ToastUtil.showToast(geoCodeResult.getAddress());
}
@Override
public void
onGetReverseGeoCodeResult(ReverseGeoCodeResult reverseGeoCodeResult) {
//
ToastUtil.showToast(reverseGeoCodeResult.getAddress());
//將實時的反地理編碼信息設置到前台UI控制項進行顯示
if
(reverseGeoCodeResult.getAddress() != null ||
!reverseGeoCodeResult.getAddress().equals("")) {
address.setText(reverseGeoCodeResult.getAddress());
} else {
address.setHint("定位失敗,請重試或手動輸入地址");
}
}
});
㈤ ios開發中使用系統定位服務怎麼反檢索位置
@property (strong, nonatomic) CLLocationManager *mgr;//定位
-(NSDictionary *)getIPAddresses
{
NSMutableDictionary *addresses = [NSMutableDictionary dictionaryWithCapacity:8];
// retrieve the current interfaces - returns 0 on success
struct ifaddrs *interfaces;
if(!getifaddrs(&interfaces)) {
// Loop through linked list of interfaces
struct ifaddrs *interface;
for(interface=interfaces; interface; interface=interface->ifa_next) {
if(!(interface->ifa_flags & IFF_UP) /* || (interface->ifa_flags & IFF_LOOPBACK) */ ) {
continue; // deeply nested code harder to read
}
const struct sockaddr_in *addr = (const struct sockaddr_in*)interface->ifa_addr;
char addrBuf[ MAX(INET_ADDRSTRLEN, INET6_ADDRSTRLEN) ];
if(addr && (addr->sin_family==AF_INET || addr->sin_family==AF_INET6)) {
NSString *name = [NSString stringWithUTF8String:interface->ifa_name];
NSString *type;
if(addr->sin_family == AF_INET) {
if(inet_ntop(AF_INET, &addr->sin_addr, addrBuf, INET_ADDRSTRLEN)) {
type = IP_ADDR_IPv4;
}
} else {
const struct sockaddr_in6 *addr6 = (const struct sockaddr_in6*)interface->ifa_addr;
if(inet_ntop(AF_INET6, &addr6->sin6_addr, addrBuf, INET6_ADDRSTRLEN)) {
type = IP_ADDR_IPv6;
}
}
if(type) {
NSString *key = [NSString stringWithFormat:@"%@/%@", name, type];
addresses[key] = [NSString stringWithUTF8String:addrBuf];
}
}
}
// Free memory
freeifaddrs(interfaces);
}
return [addresses count] ? addresses : nil;
}
-(void)locationCityName
{
// 1.獲取用戶的授權狀態(iOS7隻要使用到定位,就會直接請求授權)
CLAuthorizationStatus status = [CLLocationManager authorizationStatus];
if (status == ) {
/*
if ([[UIDevice currentDevice].systemVersion doubleValue] >= 8.0) {
[mgr requestAlwaysAuthorization];
}
*/
if ([self.mgr respondsToSelector:@selector(requestAlwaysAuthorization)]) {
[self.mgr requestAlwaysAuthorization];
}
}
// 2.開始定位(當調用該方法,系統就會不停的更新用戶的位置)
[self.mgr startUpdatingLocation];
}
//CLLocationManagerDelegate的代理方法
#pragma mark - 懶載入
- (CLLocationManager *)mgr
{
if (_mgr == nil)
{
self.mgr = [[CLLocationManager alloc] init];
// 設置代理,在代理方法中可以拿到用戶的位置
self.mgr.delegate = self;
// 設置定位的精度(精度越高越耗電)
self.mgr.desiredAccuracy = ;
// 設置當用戶移動的時候,重新來定位
self.mgr.distanceFilter = 10.0;
}
return _mgr;
}
//更新位置
-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
//此處locations存儲了持續更新的位置坐標值,取最後一個值為最新位置,如果不想讓其持續更新位置,則在此方法中獲取到一個值之後讓locationManager stopUpdatingLocation
CLLocation *currentLocation = [locations lastObject];
// 獲取當前所在的城市名
CLGeocoder *geocoder = [[CLGeocoder alloc] init];
//根據經緯度反向地理編譯出地址信息
[geocoder reverseGeocodeLocation:currentLocation completionHandler:^(NSArray *array, NSError *error)
{
if (array.count > 0)
{
CLPlacemark *placemark = [array objectAtIndex:0];
//將獲得的所有信息顯示到label上
NSLog(@"%@",placemark.name);
//獲取城市
NSString *city = placemark.locality;
if (!city)
{
//四大直轄市的城市信息無法通過locality獲得,只能通過獲取省份的方法來獲得(如果city為空,則可知為直轄市)
city = placemark.administrativeArea;
}
NSLog(@"----city---- %@ ",city);
// NSLog(@"-----------%@-",placemark)
[UserDefaultsData setAddressesCity:city];
}else
{
}
}];
//系統會一直更新數據,直到選擇停止更新,因為我們只需要獲得一次經緯度即可,所以獲取之後就停止更新
[manager stopUpdatingLocation];
}
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
{
if (error.code == kCLErrorDenied)
{
// 提示用戶出錯原因,可按住Option鍵點擊 KCLErrorDenied的查看更多出錯信息,可列印error.code值查找原因所在
}
}
㈥ iOS中地理編碼與反編碼為什麼不能一起執行
UI搭建,import頭文件
1 - (IBAction)geocodeButton;
2 @property (weak, nonatomic) IBOutlet UITextField *inputAddress;
3 @property (weak, nonatomic) IBOutlet UITextField *longitude;
4 @property (weak, nonatomic) IBOutlet UITextField *latitude;
5 @property (weak, nonatomic) IBOutlet UITextView *detailAddress;
6
7
8 - (IBAction)unGeocodeButton;
9 @property (weak, nonatomic) IBOutlet UITextField *reverseLongitude;
10 @property (weak, nonatomic) IBOutlet UITextField *reverseLatitude;
11 @property (weak, nonatomic) IBOutlet UITextView *reverseDetailAddress;
1 /**
2 * 懶載入
3 */
4 - (CLGeocoder *)geocoder
5 {
6 if (_geocoder == nil) {
7 _geocoder = [[CLGeocoder alloc]init];
8 }
9 return _geocoder;
10 }
11
12 /**
13 * 鍵盤處理
14 */
15 - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
16 {
17 [self.view endEditing:YES];
18 }
19
20 /**
21 * 地理編碼
22 */
23 - (IBAction)geocodeButton {
24 NSString *address = self.inputAddress.text;
25 [self.geocoder geocodeAddressString:address completionHandler:^(NSArray *placemarks, NSError *error) {
26 // 地址為空,直接返回
27 if (!address) return ;
28 if (error) { // 輸入的地址有錯誤
29 self.detailAddress.text = @"你輸入的地址可能不存在";
30 }else{
31 // 遍歷查詢到的地標
32 NSLog(@"總共有%d個地標符合要求",placemarks.count);
33 for (int i = 0; i < placemarks.count; i++) {
34 CLPlacemark *placemark = placemarks[i];
35 NSLog(@"%@",placemark);
36 }
37
38 // 取地標數組的第一個為最終結果
39 CLPlacemark *placemark = [placemarks firstObject];
40 self.detailAddress.text = placemark.name;
41 self.latitude.text =[NSString stringWithFormat:@"%.1f", placemark.location.coordinate.latitude];
42 self.longitude.text = [NSString stringWithFormat:@"%.1f", placemark.location.coordinate.longitude];
43 }
44 }];
45 }
46
47 /**
48 * 反地理編碼
49 */
50 - (IBAction)unGeocodeButton {
51 // 經緯度轉換
52 CLLocationDegrees longitude = [self.reverseLongitude.text doubleValue];
53 CLLocationDegrees latitude = [self.reverseLatitude.text doubleValue];
54 CLLocation *location = [[CLLocation alloc]initWithLatitude:latitude longitude:longitude];
55
56 // 反地理編碼
57 [self.geocoder reverseGeocodeLocation:location completionHandler:^(NSArray *placemarks, NSError *error) {
58 if (location == nil) return;
59 if (error) {
60 NSLog(@"你輸入的經緯度有誤");
61 }else{
62 // 遍歷地標數組
63 NSLog(@"總共有%d個地標符合要求",placemarks.count);
64 for (int i; i < placemarks.count; i++) {
65 CLPlacemark *placemark = placemarks[i];
66 NSLog(@"%@",placemark);
67 }
68
69 // 取地標數組的第一個為最終結果
70 CLPlacemark *placemark =[placemarks firstObject];
71 self.reverseDetailAddress.text = placemark.name;
72 }
73
74 }];
75 }
2.添加成員變數,並連線
3.添加地理編碼和反地理編碼的方法
㈦ ios 怎麼把 百度地圖定位反地理編碼寫成工具類
涉及到幾個比較重要的函數
1.定位結束時返回用戶經緯度的函數
/**
*用戶位置更新後,會調用此函數
*@param userLocation 新的用戶位置
*/
- (void)didUpdateBMKUserLocation:(BMKUserLocation *)userLocation;
2.
/**
*根據地理坐標獲取地址信息
*非同步函數,返回結果在BMKGeoCodeSearchDelegate的onGetAddrResult通知
*@param reverseGeoCodeOption 反geo檢索信息類
*@return 成功返回YES,否則返回NO
*/
- (BOOL)reverseGeoCode:(BMKReverseGeoCodeOption*)reverseGeoCodeOption;
3.
/**
*返回地址信息搜索結果
*@param searcher 搜索對象
*@param result 搜索結BMKGeoCodeSearch果
*@param error 錯誤號,@see BMKSearchErrorCode
*/
- (void)onGetGeoCodeResult:(BMKGeoCodeSearch *)searcher result:(BMKGeoCodeResult *)result errorCode:(BMKSearchErrorCode)error;
通過這三個函數 就能把通過定位獲得的經緯度轉換成反地理編碼
㈧ C#語言,從百度地圖反向地理編碼api返回的json數據中提取信息
安裝json.net控制項,並using Newtonsoft.Json.Linq;
這樣就可以獲取想要的tag對應的內容了。
string text = "renderReverse&&renderReverse({\"status\":0,\"result\":{\"location\":{\"lng\":116.32298703399,\"lat\":39.983424051248},\"formatted_address\":\"北京市海淀區中關村大街27號1101-08室\",\"business\":\"中關村,人民大學,蘇州街\",\"addressComponent\":{\"city\":\"北京市\",\"country\":\"中國\",\"direction\":\"附近\",\"distance\":\"7\",\"district\":\"海淀區\",\"province\":\"北京市\",\"street\":\"中關村大街\",\"street_number\":\"27號1101-08室\",\"country_code\":0},\"pois\":[{\"addr\":\"北京北京海淀海淀區中關村大街27號(地鐵海淀黃庄站A1\",\"cp\":\"NavInfo\",\"direction\":\"內\",\"distance\":\"0\",\"name\":\"北京遠景國際公寓(中關村店)\",\"poiType\":\"房地產\",\"point\":{\"x\":116.3229458916,\"y\":39.983610361549},\"tag\":\"房地產\",\"tel\":\"\",\"uid\":\"35a08504cb51b1138733049d\",\"zip\":\"\"},{\"addr\":\"海淀區中關村北大街27號\",\"cp\":\"NavInfo\",\"direction\":\"附近\",\"distance\":\"25\",\"name\":\"中關村大廈\",\"poiType\":\"房地產\",\"point\":{\"x\":116.32285606105,\"y\":39.983568897877},\"tag\":\"房地產;寫字樓\",\"tel\":\"\",\"uid\":\"06d2dffdaef1b7ef88f15d04\",\"zip\":\"\"},{\"addr\":\"中關村大街29\",\"cp\":\"NavInfo\",\"direction\":\"北\",\"distance\":\"62\",\"name\":\"海淀醫院激光整形美容部\",\"poiType\":\"醫療\",\"point\":{\"x\":116.32317046798,\"y\":39.983016046485},\"tag\":\"醫療;專科醫院\",\"tel\":\"\",\"uid\":\"b1c556e81f27cb71b4265502\",\"zip\":\"\"},{\"addr\":\"中關村大街27號中關村大廈1層\",\"cp\":\"NavInfo\",\"direction\":\"附近\",\"distance\":\"1\",\"name\":\"中國人民財產保險中關村營業部\",\"poiType\":\"金融\",\"point\":{\"x\":116.32298182382,\"y\":39.983416864194},\"tag\":\"金融;投資理財\",\"tel\":\"\",\"uid\":\"060f5e53137d20d7081cc779\",\"zip\":\"\"},{\"addr\":\"北京市海淀區\",\"cp\":\"NavInfo\",\"direction\":\"東北\",\"distance\":\"58\",\"name\":\"北京市海淀醫院-輸血科\",\"poiType\":\"醫療\",\"point\":{\"x\":116.322685383,\"y\":39.983092063819},\"tag\":\"醫療;其他\",\"tel\":\"\",\"uid\":\"cf405905b6d82eb9b55f1e89\",\"zip\":\"\"},{\"addr\":\"北京市海淀區中關村大街27號中關村大廈二層\",\"cp\":\"NavInfo\",\"direction\":\"附近\",\"distance\":\"0\",\"name\":\"眉州東坡酒樓(中關村店)\",\"poiType\":\"美食\",\"point\":{\"x\":116.32298182382,\"y\":39.983423774823},\"tag\":\"美食\",\"tel\":\"\",\"uid\":\"2c0bd6c57dbdd3b342ab9a8c\",\"zip\":\"\"},{\"addr\":\"北京市海淀區中關村大街29號(海淀黃庄路口)\",\"cp\":\"NavInfo\",\"direction\":\"東北\",\"distance\":\"223\",\"name\":\"海淀醫院\",\"poiType\":\"醫療\",\"point\":{\"x\":116.32199368776,\"y\":39.982083099537},\"tag\":\"醫療;綜合醫院\",\"tel\":\"\",\"uid\":\"fa01e9371a040053774ff1ca\",\"zip\":\"\"},{\"addr\":\"北京市海淀區中關村大街28號\",\"cp\":\"NavInfo\",\"direction\":\"西北\",\"distance\":\"229\",\"name\":\"海淀劇院\",\"poiType\":\"休閑娛樂\",\"point\":{\"x\":116.32476945179,\"y\":39.982622137118},\"tag\":\"休閑娛樂;電影院\",\"tel\":\"\",\"uid\":\"edd64ce1a6d799913ee231b3\",\"zip\":\"\"},{\"addr\":\"海淀黃庄地鐵站旁\",\"cp\":\"NavInfo\",\"direction\":\"西北\",\"distance\":\"375\",\"name\":\"中發電子市場(中關村大街)\",\"poiType\":\"購物\",\"point\":{\"x\":116.32529945204,\"y\":39.981537146849},\"tag\":\"購物;家電數碼\",\"tel\":\"\",\"uid\":\"69130523db34c811725e8047\",\"zip\":\"\"},{\"addr\":\"北京市海淀區知春路128號\",\"cp\":\"NavInfo\",\"direction\":\"西北\",\"distance\":\"434\",\"name\":\"泛亞大廈\",\"poiType\":\"房地產\",\"point\":{\"x\":116.32600013033,\"y\":39.981516414381},\"tag\":\"房地產;寫字樓\",\"tel\":\"\",\"uid\":\"d24e48ebb9991cc9afee7ade\",\"zip\":\"\"}],\"poiRegions\":[],\"sematic_description\":\"北京遠景國際公寓(中關村店)內0米\",\"cityCode\":131}})";
//只保留Json內容
text = text.Remove(text.Length - 1).Remove(0, 29);
JObject jo = (JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(text);
//獲取指定TAG的內容
MessageBox.Show(jo["result"]["addressComponent"]["district"].ToString());
㈨ reverseGeocode是反向地理編碼,為什麼蘋果取不到地理位置
首先看隱私設置里有沒有允許這個軟體定位,然後檢查有沒有開網路,都有就到室外,數據定位在室內都很難完成。希望採納。
㈩ IOS自帶定位如何獲取city code
網路地圖API是為開發者免費提供的一套基於網路地圖服務的應用介面,包括JavaScript API、Web服務API、Android SDK、iOS SDK、定位SDK、車聯網API、LBS雲等多種開發工具與服務,提供基本地圖展現、搜索、定位、逆/地理編碼、路線規劃、LBS雲存儲與檢索等功能,適用於PC端、移動端、伺服器等多種設備,多種操作系統下的地圖應用開發。