我正在尝试两个位置之间的两条绘制路线,为此我从 Google Map API Web Service 获取所有点。(JSON
输出格式)。在解析 JSON
数据和解码点后,我将所有点存储在 NSMutableArray
上。
每个索引数组都包含这种类型的值。
"<+10.90180969, +76.19167328> +/- 0.00m (speed -1.00 mps / course -1.00) @ 12/04/12 10:18:10 AM India Standard Time",
现在我想分离纬度和经度值。
latitude : +10.90180969
longitude : +76.19167328
如何从数组的每个索引中获取这些值?
这只是一种方法。
NSString* str = @"<+10.90180969, +76.19167328> +/- 0.00m (speed -1.00 mps / course -1.00) @ 12/04/12 10:18:10 AM India Standard Time";//you already have this string.
str = (NSString*)[[str componentsSeparatedByString">"] objectAtIndex:0];
// after above performed step, str equals "<+10.90180969, +76.19167328"
str = [str substringFromIndex:1];
// after above performed step, str equals "+10.90180969, +76.19167328"
NSString* strLat = (NSString*)[[str componentsSeparatedByString","] objectAtIndex:0];
NSString* strLon = (NSString*)[[str componentsSeparatedByString","] objectAtIndex:1];
// after above performed step, strLat equals "+10.90180969"
// after above performed step, strLon equals " +76.19167328"
strLon = [strLon substringFromIndex:1];//<-- to remove the extra space at index=0
关于iphone - 如何从 JSON 输出中分离纬度和经度值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10117738/
欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) | Powered by Discuz! X3.4 |