您的位置:首页 > 移动开发 > Objective-C

objective-c高德地图时时定位

2016-01-07 11:42 441 查看
这篇随笔是对上一遍servlet接口的实现。

一、项目集成高德地图

应为我这个项目使用了cocopods这个第三方库管理工具,所以只需要很简单的步骤,就能将高德地图集成到项目中,如果你没使用过这工具,那就直接下载对应的sdk导入即可,因为这个工具的安装还是比较麻烦的,需要FQ。 既然我用的这种方式,下面我就贴相关的使用接图。

- (void)mapViewDidStopLocatingUser:(MAMapView *)mapView
{

_longitude=[NSString stringWithFormat:@"%f",mapView.userLocation.location.coordinate.longitude];//@"106.546128";//
_latitude= [NSString stringWithFormat:@"%f",mapView.userLocation.location.coordinate.latitude];          //@"29.559153";

[WDUser currentUser].longitude=_longitude;
[WDUser currentUser].latitude=_latitude;
[[WDUser currentUser] saveUserInfo];

_search = [[AMapSearchAPI alloc] initWithSearchKey:@"?" Delegate:self];
AMapReGeocodeSearchRequest *regeoRequest = [[AMapReGeocodeSearchRequest alloc] init];
regeoRequest.searchType = AMapSearchType_ReGeocode;

regeoRequest.location =[AMapGeoPoint locationWithLatitude:[_latitude floatValue] longitude:[_longitude floatValue]];
regeoRequest.radius = 10000;
regeoRequest.requireExtension = YES;

//发起逆地理编码
[_search AMapReGoecodeSearch: regeoRequest];

}
//逆编码查询代理
- (void)onReGeocodeSearchDone:(AMapReGeocodeSearchRequest *)request response:(AMapReGeocodeSearchResponse *)response
{

if(response.regeocode != nil)
{

_compantAddress=response.regeocode.addressComponent;

_currentCityName=_compantAddress.province;

_currentCityName=  [_currentCityName stringByReplacingOccurrencesOfString:@"市" withString:@""];
_currentCityName=  [_currentCityName stringByReplacingOccurrencesOfString:@"省" withString:@""];

[ WDUser currentUser].currentCity=_currentCityName;
[[WDUser currentUser] saveUserInfo];

[SVProgressHUD dismiss];
}
else{
showMessage(@"请检查网是否畅通!");
}

}
- (void)mapView:(MAMapView *)mapView didUpdateUserLocation:(MAUserLocation *)userLocation
{

mapView.showsUserLocation = NO;

}//联系客户


View Code
最后服务人员将这些获取的参数提交到servlet处理。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: