|
|
|
iOS ช่วยด้วยคะ เรื่อง Get cullentlocation บน google map sdk แล้วค่าที่ได้เป็น 0.0000 ตลอดเลยคะ |
|
|
|
|
|
|
|
Code (Objective-C)
#import "Googlemap.h"
#import <GoogleMaps/GoogleMaps.h>
#import <CoreLocation/CoreLocation.h>
@interface Googlemap ()
{
GMSMapView *mapView_;
}
@end
@implementation Googlemap{
CLLocationManager *locationManager;
}
@synthesize inLat;
@synthesize inLong;
@synthesize inName;
GMSMapView *mapView_;
- (void)loadView {
............
}
- (void)viewDidLoad
{
[super viewDidLoad];
locationManager = [[CLLocationManager alloc] init];
NSLog(@"locationServicesEnabled: %@", [CLLocationManager locationServicesEnabled] ? @"YES":@"NO");
CLLocationManager *lm = [[CLLocationManager alloc] init];
lm.delegate = self;
lm.desiredAccuracy = kCLLocationAccuracyBest;
lm.distanceFilter = kCLDistanceFilterNone;
[lm startUpdatingLocation];
//[lm stopUpdatingLocation];
CLLocation *location = [lm location];
CLLocationCoordinate2D coord;
coord.longitude = location.coordinate.longitude;
NSString *ss= [NSString stringWithFormat:@"%.8f",coord.longitude ];
coord.latitude = location.coordinate.latitude;
NSString *aa= [NSString stringWithFormat:@"%.8f",coord.latitude ];
NSLog(@"oooooooo2");
NSLog(@"%@",ss);
NSLog(@"%@",aa);
NSLog(@"kkkkkkkkk2");
}
- (IBAction)getLocation:(id)sender
{
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
[locationManager startUpdatingLocation];
}
#pragma mark - CLLocationManagerDelegate
-(void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
{
NSLog(@"didFailWithError: %@",error);
UIAlertView *errorAlert = [[UIAlertView alloc] initWithTitle:@"ERROR" message:@"Failed" delegate:nil
cancelButtonTitle:@"OK" otherButtonTitles:nil];[errorAlert show];
}
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
NSLog(@"vvvvvvvv");
[manager stopUpdatingLocation];
NSLog(@"%@",newLocation.coordinate.latitude);
NSLog(@"%@",newLocation.coordinate.longitude);
}
@end
รันผ่านไม่มีปัญหาอะไร แต่ส่งค่าพิกัดละติจุด และลองติจูด เป็น 0.0000 ตลอดเลยคะ
Tag : Mobile, iOS, Objective-C, Mobile
|
|
|
|
|
|
Date :
2014-08-31 17:02:51 |
By :
pmars |
View :
965 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
http://www.tutorialspoint.com/ios/ios_location_handling.htm
|
|
|
|
|
Date :
2014-09-01 17:25:50 |
By :
air |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|