Android谷歌地图地理编码,使用谷歌地图api iOS反向地理编码

我正在使用以下代码进行反向地理编码

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation

{

curLoc=newLocation;

if (curLoc != nil) {

latitude=curLoc.coordinate.latitude;

longitude=curLoc.coordinate.longitude;

//[self loadMap:latitude second:longitude];

[self MarkerPoint:latitude+0.04 second:longitude+0.1 third:latitude-0.04 forth:longitude-0.1];

NSError *error;

NSString *lookupString = [NSURL URLWithString:[NSString stringWithFormat:@"http://maps.googleapis.com/maps/api/geocode/json?latlng=%f,%f&sensor=false",latitude,longitude]];

NSLog(@"URL: %@",lookupString);

lookupString = [lookupString stringByReplacingOccurrencesOfString:@" " withString:@"+"];

NSData *jsonResponse = [NSData dataWithContentsOfURL:[NSURL URLWithString:lookupString]];

NSDictionary *jsonDict = [NSJSONSerialization JSONObjectWithData:jsonResponse options:kNilOptions error:&error];

self.locationArray = [[jsonDict valueForKey:@"results"] valueForKey:@"formatted_address"];

int total = self.locationArray.count;

NSLog(@"locationArray count: %d", self.locationArray.count);

for (int i = 0; i < total; i++)

{

NSString *statusString = [jsonDict valueForKey:@"status"];

NSLog(@"JSON Response Status:%@", statusString);

NSLog(@"Address: %@", [self.locationArray objectAtIndex:i]);

}

}

}

现在我收到此错误:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSURL stringByReplacingOccurrencesOfString:withString:]: unrecognized selector sent to instance 0xbce98c0'

*** First throw call stack:

(

0 CoreFoundation 0x034551e4 __exceptionPreprocess + 180

1 libobjc.A.dylib 0x031a98e5 objc_exception_throw + 44

2 CoreFoundation 0x034f2243 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275

3 CoreFoundation 0x0344550b ___forwarding___ + 1019

4 CoreFoundation 0x034450ee _CF_forwarding_prep_0 + 14

5 MatchPoint 0x00017fad -[ICSViewController locationManager:didUpdateToLocation:fromLocation:] + 813

6 CoreLocation 0x0164655e CLLocationCoordinate2DGetDistanceFrom + 18294

7 CoreLocation 0x01645af4 CLLocationCoordinate2DGetDistanceFrom + 15628

8 CoreLocation 0x01642e40 CLLocationCoordinate2DGetDistanceFrom + 4184

9 CoreLocation 0x0163c680 CLClientInvalidate + 996

10 CoreFoundation 0x034140b0 __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 16

11 CoreFoundation 0x033dd339 __CFRunLoopDoBlocks + 361

12 CoreFoundation 0x033fb753 __CFRunLoopRun + 2355

13 CoreFoundation 0x033fa9d3 CFRunLoopRunSpecific + 467

14 CoreFoundation 0x033fa7eb CFRunLoopRunInMode + 123

15 GraphicsServices 0x051f05ee GSEventRunModal + 192

16 GraphicsServices 0x051f042b GSEventRun + 104

17 UIKit 0x01e69f9b UIApplicationMain + 1225

18 MatchPoint 0x0001d9fd main + 141

19 libdyld.dylib 0x03d206d9 start + 1

20 ??? 0x00000001 0x0 + 1

)

libc++abi.dylib: terminating with uncaught exception of type NSException

(lldb)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值