//ViewController.hzeigen, wie Länge, Breite in Etikett des gleichen Code
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
#import <CoreLocation/CoreLocation.h>
@interface ViewController : UIViewController<CLLocationManagerDelegate,MKMapViewDelegate>
@property (weak, nonatomic) IBOutlet UILabel *addresslbl;
@property (weak, nonatomic) IBOutlet MKMapView *mapView;
@end
//Viewcontroller.m
#import "ViewController.h"
@interface ViewController()
{
CLLocationManager *locationManager;
CLLocationCoordinate2D updateLocation;
NSString *strAddress;
CLGeocoder *geocoder;
}
@end
@implementation ViewController
#define AzaveaCoordinate CLLocationCoordinate2DMake(19.167391, 73.247686)
- (void)viewDidLoad {
[super viewDidLoad];
[_mapView setRegion:MKCoordinateRegionMake(AzaveaCoordinate, MKCoordinateSpanMake(0.010, 0.010)) animated:YES];
geocoder = [[CLGeocoder alloc]init];
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
[locationManager requestWhenInUseAuthorization];
self.mapView.delegate = self;
}
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
{
NSLog(@"didFailWithError: %@", error);
}
-(void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated
{
CLLocation *location = [[CLLocation alloc]initWithLatitude:mapView.centerCoordinate.latitude longitude:mapView.centerCoordinate.longitude];
[self geocode:location];
}
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation
{
CLLocation *currentLocation = newLocation;
self.mapView.centerCoordinate = currentLocation.coordinate;
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(currentLocation.coordinate,1500,1500);
[self.mapView setRegion: region animated:true];
[self geocode:currentLocation];
}
-(void)geocode:(CLLocation *)location
{
// geocoder = [[CLGeocoder alloc]init];
[geocoder cancelGeocode];
[geocoder reverseGeocodeLocation:location completionHandler:^(NSArray *data, NSError *error)
{
CLPlacemark *placemark = [data lastObject];
NSDictionary * addressDict = placemark.addressDictionary;
NSArray * addressList = addressDict[@"FormattedAddressLines"];
NSString * address = [NSString stringWithFormat:@"%@,%@,%@",addressList[0],addressList[1],addressList[2]];
NSLog(@" Address is :%@",address);
self.addresslbl.text = address;
}];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
Dies ist der bewegliche Karte Code wie ola und uber. Bedeutet, wenn ich die Karte bewege, zu dieser Zeit wird der Kartenstift bemerkt, der notierte Stift wird mir Adresse des bestimmten bestimmten Bereichs wie Stadt, Staat, Pincode usw. im Etikett gegeben, aber ich will nur den Längen-, Breitengradwert dieser Adresse in Etikett.
also bitte helfen Sie mir über diesen Code. Wie kann ich den Längengrad-Breitenwert erhalten?
Dank R.lin .thanks ein lot..its – NARAYAN
Arbeits OK gut wenn du die Antwort akzeptieren könntest, die gut wäre. @ NARAYAN –