高徳地図---表示、位置決め、逆符号化

3011 ワード

[AMapServices sharedServices].apiKey = @"80985a4a5ea3794dd8155f9a4973526b";

pragma mark-地図の作成


-(void)createMap{
/// 
self.mapView = [[MAMapView alloc] initWithFrame:CGRectMake(0, self.topView.bottom, SCREENWIDTH, SCREENHEIGHT - self.topView.bottom)];
self.mapView.showsCompass = NO; //  
self.mapView.showsScale = NO; //  
self.mapView.language = MAMapLanguageZhCN;
self.mapView.mapType = MAMapTypeStandard;
self.mapView.zoomLevel = 17;
self.mapView.delegate = self;
/// , 
self.mapView.showsUserLocation = YES;
self.mapView.userTrackingMode = MKUserTrackingModeFollow;
/// view
[self.view addSubview:self.mapView];

}//MARK:-位置決め開始
  • (void)startLocation{self.locationManager=[[AMapLocationManager alloc] init];self.locationManager.delegate=self;self.locationManager.distanceFilter=kCLDistanceFilterNone;//CLLocationManagerオブジェクトの戻り結果を可能な限り正確にするように要求する[self.locationManager setDesiredAccuracy:kCLLocationAccuracyBest];[self.locationManager setionManager setPausesLousesLousesLousesLousesLousesLousesLousesLousesLouses];[self.locationManager self.locationManager setManager setManager cationUpdatesAutomatically:NO];[self.locationManager setAllowsBackgroundLocationUpdates:YES];//継続的な位置決めは逆地理符号化情報を返す[self.locationManager setLocatingWithReGeocode:YES];[self.locationManager startUpdatingLocation]; self.search = [[AMapSearchAPI alloc] init]; self.search.delegate = self; }//MARK:-受信位置更新
  • (void)amapLocationManager:(AMapLocationManager*)manager didUpdateLocation:(CLLocation*)location{NSLog(@「location:{緯度:%f;経度:%f;accuracy:%f}」,location.cordinate.latitude,location.cordinate.longitude,location.horizontalAccuracy);NSUserDefaults *userStr = [NSUserDefaults standardUserDefaults]; [userStr setFloat:location.coordinate.longitude forKey:@"lngLat.lng"]; [userStr setFloat:location.coordinate.latitude forKey:@"lngLat.lat"]; [userStr synchronize];//アンチコーディングAMapReGeocodeSearchRequest regeo=[[A m a p ReGeocodeSearchRequest alloc]init];regeo.location = [AMapGeoPoint locationWithLatitude:location.coordinate.latitude longitude:location.coordinate.longitude]; NSLog(@"%f--%f",location.coordinate.latitude,location.coordinate.longitude); regeo.requireExtension = YES;//逆地理符号化を開始するMARK:-逆符号化/逆地理符号化コールバック.*/
  • (void)onReGeocodeSearchDone:(AMapReGeocodeSearchRequest*)request response:(AMapReGeocodeSearchResponse*)response{if(response.regeocode!=nil){///解析response取得アドレス記述NSLog(@「逆符号化:%@」,response.regeocode.addressComponent.township);self.topLabel.text=response=response=response.ponse.regeocode.addressComponent.township;NSUserDefaults*userStr=[NSUserDefaults standardUserDefaults];[userStr setObject:response.regeocode.addressComponent.township forKey:@"pointName"]; [userStr synchronize]; }else{self.topLabel.text=@「ホットスポット情報が一時的に存在しない」;[self.locationManager stopUpdatingLocation]; }
  • (void)AMapSearchRequest:(id)request didFailWithError:(NSError *)error{ NSLog(@"error:%@",error); }