我正在编写一个iOS应用程序,用于确定一组地址之间的最佳路径。我目前正在使用Google Distance Matrix。我可以成功发送请求,但在发送1个原点和2个目的地后,它返回null。
NSString *address0 = @"111 Main St City ST 55555";
NSString *address1 = @"222 Main St City ST 5555";
NSString *address2 = @"333 Main St City ST 5555";
NSString *escAddress0 = [address0 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSString *escAddress1 = [address1 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSString *escAddress2 = [address2 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSString *request = [NSString stringWithFormat:@"https://maps.googleapis.com/maps/api/distancematrix/json?origins=%@&destinations=%@|%@&language=en-EN&key={APIKEY}", escAddress0,escAddress1,escAddress2];
NSString *result = [NSString stringWithContentsOfURL:[NSURL URLWithString:request] encoding:NSUTF8StringEncoding error:nil];
NSLog(@"result: %@ ", result)
Directions API对于这样的事情是更好的选择吗?并且有一个很好的理由它会返回null。有什么明显的我做错了吗?我在使用服务和API方面有点新手