㈠ 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端、移动端、服务器等多种设备,多种操作系统下的地图应用开发。