我正在申请显示从A点到B点的行车路线 我正在使用IOS地图套件 首先,我从谷歌获取路线信息,如:
http://maps.googleapis.com/maps/api/directions/xml?origin=44.00771,20.911982&waypoints=44.814785,20.419936&sensor=false
这将返回XML我从返回的XML中的“steps”中解析经度和纬度,并使用它在地图上绘制路线。
问题是这条画线路但不完整
我认为返回的XML中没有足够的信息来绘制完整的路径,我想知道这是怎么可能的
我在网络谷歌地图上键入这两个位置,它绘制路线很好。所以它必须是这个XML中没有包含足够的信息或者我在这里做错了什么,我是否正在调用正确的Web服务?
当我从这条线上的波纹管应用程序中传递点时:
do {
b = [encoded characterAtIndex:index++] - 63;
有错误:
**Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSCFString characterAtIndex:]: Range or index out of bounds'**
aprkGmus~B?UHk@b@{BTkBL}A@_AGk@WiAc@kBUaBOgC?KGiAMmAWsA_@uAYmA_@qA[oAI[Uy@IUQg@_AaBs@y@kAk@_Bi@y@]m@c@Y_@[c@IOOUMWCEiAsAy@{@aCiBqCkBiAeA_BkBkBiByDeD]YyDgDmBqBq@s@sA}Ak@s@cAgAiAqAcBcBsLqJmI{Gq@o@cAu@s@s@gA}@MIk@k@a@_@gAaAcPiRUKY_@{BmCaKcLoQqVEIe]kl@eJqP{Pk[sWoe@cEiE_@a@sH_I}IiIGEaFoE]YkAcAqF_FeFwEcEuEcCaDaDaFmAwBwAoCeDqHiJsTkDyHmAaCg@aA}BsE{D}GsGuJiIoJk@q@oB{ByCmDmHaI_DmCcBgAYOsBaA{@YeBo@aEoA{D{A}HgEaEkCeDeCeC}Bs@q@sEqDg@a@aFuBkFaAiEOaHBeHg@mBi@kCq@c@Mu@UwE}A]IOEe@OgIeBsIw@}GMuCJoB\kC`Am@`@iBjAaFpEoCrC{AzAgB|AqBhAsDfAyDRuD_@gCaAiCgBgCuCY_@qBqCSYIK{@oAIIiAmAYYcA}@cCmBmCaBiAe@yDiAuDs@oDw@_Bi@uCu@OGME_Cu@{D}AuDkBcDkBaD}BaDe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@`@e@d@uAbBoAbBc@f@i@d@a@Zc@Z{@b@a@NoAZkARq@LoAPq@Ps@XmBdAcBdA_Ah@IDc@Tq@Ts@Ry@Le@DS@cAA}@Cy@KwBWwAOaBEmAFk@F_@Dy@Rm@TmAj@u@d@s@j@qApAu@~@Yb@Wb@CBQVSXy@nA_ArAq@bASZsAxAc@f@YVo@d@uA|@eAf@oBv@gA\w@RiBb@qAZuA\gA`@u@Xi@XOHc@VmA~@q@p@q@p@SV[`@q@bAQXk@fAMRg@jAg@zAa@lAaB|EeB|EiApCq@xAkAfCi@|@mAnBkAfB}@fA]^gAnA_AbAi@h@}AnAmA|@mCfB_CxAiDrBaD`CwBnBQNqBxBGFWXWX{C|Dq@~@m@bAiBzCwBtDiCfFS`@o@vA_CdF}@tBaAbCu@nBcArC}@tCa@pA]hAIZc@|AAFu@`D{@nDa@~Bg@hCCHg@rDYjBId@g@zDKjACXCLUbC]tEa@`IUnEAb@c@nIWlF]pI[rGMjDSrEUrDUnCoA`Jo@`D]zAaApDuBfH{@pCa@xACDcArDw@hCu@fC]fAs@~Bs@~BcBtF_AxCiAzD{@jCm@fB{BzFaEtIyCnFyFvISZKPU^KPKPWb@ABS^SXABkAfBqAzBGHEHILCDyAzCiBtEkAtDs@fC[pAm@nC_@lBYlBq@dFw@zFq@hF]zBGb@EVEVKn@c@rCa@bBWfAe@hBs@rBmAbDOZa@~@ITyAjDUj@e@hAMXQb@EJUf@IPGPe@fASf@EJIPaBxDWn@eBdEiBlEe@fA{ArDM\]v@sDtIkBtEA@gAnC]z@iAjCm@xAoAbDMZ[x@CD}BdGiAdDSj@Ob@]`AMZk@`BkFxNm@dBw@|BKXITEJ[`AYt@oBxFiBlFABw@xBKZ
答案 0 :(得分:7)
这个异常发生becoz数组越界....在你的解码方法中只使用简单的参数字符串....他们不需要方法“replaceoccuranceof string method”....只是使用简单的字符串没有这个方法........
[encoded replaceOccurrencesOfString:@“\\”withString:@“\” 选项:NSLiteralSearch range:NSMakeRange(0,[编码长度])];
从代码中删除以上行....没有发生nsrangeexception ......
答案 1 :(得分:1)
你可以看到这个例子来解决你的问题 https://github.com/kishikawakatsumi/MapKit-Route-Directions
答案 2 :(得分:0)
我之前回答了类似的问题,请参阅此link以及您在本回答的评论中所寻求的内容......
答案 3 :(得分:0)
我找到另一种方法来获取路线的坐标我称之为服务:
http://maps.google.com/maps?f=d&hl=en&saddr=44.00771,20.911982&daddr=44.814785,20.419936&ie=UTF8&0&om=0&output=kml
它返回一个包含所有值的文件