带有折线的静态地图api url从cordova文件传输插件获取uriEncoded

时间:2016-03-02 15:43:32

标签: cordova-plugins ngcordova google-static-maps

我有一个网址,如果您复制并粘贴到浏览器中,则会显示地图:

https://maps.googleapis.com/maps/api/staticmap?&key=AIzaSyAzijDqcmwhL7jvqZ625ZfjU-WskiuVqko&size=1000x900&path=weight:12|color:0x037AFF|enc:c`sfEl~`jUzAkf@{_@aKuhAnMhBjiAkpB|nB_rAxaCooCto@esBzAkyAf|@o{AhpAsrAlS{bAZeiEej@kzC_UgfAx|@_zA~g@goDl\yyEvaAwsBlnAo_Bdp@irBr}@}kEz|@uyH~}DodF|iBooDnlCgj@trAe{CjiBggArxAowAzdAskGfsFy{AdoB}aAjVivG|gKevAp|CwsA~~B{}E`cCgrBnvCsmBf`E_Zla@ooAeh@ccAsq@ibA_BqeCz|@{Vn\_u@z@ieCcGinDiGoz@nb@ak@`{A_`AdiBwmCfdCcqEt|Cw`Cj|AitCxaCkeBpsCcqAtjD_rAbxBqxDh~CksGfdH}dFn}LiaGxbLekEv`Da`CvgCceC`bB}qCzpCo}@~sC}r@~qDsp@tm@uwA_d@wmDpd@{bDnmEep@nrAm{@bb@}cDjn@cf@|w@uwB`oBi{BxtC}oBloBox@bdAuHvfAoV|iB}hAnkDajGx}F{wGtfH{m@hZol@jzAirBbbEc}F|rBw|CthA{cAv|@iv@j|As`Avh@ylDeDkyF`fE_gC|gBi`BveBovAdmBaeBvuAqxAHuuAb\kyApyAsIjz@yl@t}@_|Btt@c_AliAcoBnlBmtA`f@yzCjWwqDqPohAnh@aoCx{Esa@duEsqAlmA_xCoeCcaD`gBaxBbzBin@p_A}y@tlAiqA`FsqBx@goB~z@s|JntBs}AjbAg_EbfEup]lj`@ssObvPagHnrKotI||MweThm[edJzcKkfHfwGc`ElnCuyP|gLihVtuP{mT`mTu{HdvIa_CjoEkvBpqEwtEbvHsqEl_EwwIfzHyoEnfCmzKfbGcrDjvBufF`oEsuKljJscPhoNkuG~~HiqN|rSuiRliNa`VryN{xLlcIaxKrqMw}Np{MmTpOePfxOkoCvyFky@zlC_lAh~@vj@dmCp_AhhAfOjrDlk@|uAbt@dn@phBbeGri@nh@@dz@cKhnAvn@~z@pa@hgDpyBx}Bxs@zgDrtA`{Ajn@vMrg@cRxs@rJrXfu@lYdhAgaAnrBaMlnAwu@l]e]b~AdPru@mA`vBizB~jDy\`d@hi@r^bWfYc[pyBmGjjAyrJpxDwwEdsBs|BzaCkqEpbDsmBlpBm|B`lCuqD|xF}qEn|ImmAxlAsoBvn@qxB~m@yeBpbBcrC`mCcbB|gB{\hhDaz@~aDm`ErrWcq@`iDmeCfqDqzDbuFkeCh~F_o@pzE_d@~eBoqBlaCujGfhGmfD|dEuOvcDspBtjDcf@nk@_G{n@sKcQ&markers=color:0xFF8F00%7Clabel:A%7C32.70735640000002,-117.1564884&markers=color:0xFF8F00%7Clabel:B%7C37.62131290000001,-122.37895540000005&style=feature:landscape|hue:0xFFBB00|saturation:43.400000000000006|lightness:37.599999999999994|gamma:1&style=feature:road|hue:0xFFC200|saturation:-61.8|lightness:45.599999999999994|gamma:1&style=feature:road|hue:0xFF0300|saturation:-100|lightness:51.19999999999999|gamma:1&style=feature:road|hue:0xFF0300|saturation:-100|lightness:52|gamma:1&style=feature:water|hue:0x0078FF|saturation:-13.200000000000003|lightness:2.4000000000000057|gamma:1&style=feature:poi|hue:0x00FF6A|saturation:-1.0989010989011234|lightness:11.200000000000017|gamma:1

但是当我将此网址传递到$cordovaFileTransfer.download方法时,它会在内部运行encodeURI,然后将网址转换为:

https://maps.googleapis.com/maps/api/staticmap?&key=AIzaSyAzijDqcmwhL7jvqZ625ZfjU-WskiuVqko&size=1000x900&path=weight:12%7Ccolor:0x037AFF%7Cenc:c%60sfEl~%60jUzAkf@%7B_@aKuhAnMhBjiAkpB%7CnB_rAxaCooCto@esBzAkyAf%7C@o%7BAhpAsrAlS%7BbAZeiEej@kzC_UgfAx%7C@_zA~g@goDl%5CyyEvaAwsBlnAo_Bdp@irBr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MlnAwu@l%5De%5Db~AdPru@mA%60vBizB~jDy%5C%60d@hi@r%5EbWfYc%5BpyBmGjjAyrJpxDwwEdsBs%7CBzaCkqEpbDsmBlpBm%7CB%60lCuqD%7CxF%7DqEn%7CImmAxlAsoBvn@qxB~m@yeBpbBcrC%60mCcbB%7CgB%7B%5ChhDaz@~aDm%60ErrWcq@%60iDmeCfqDqzDbuFkeCh~F_o@pzE_d@~eBoqBlaCujGfhGmfD%7CdEuOvcDspBtjDcf@nk@_G%7Bn@sKcQ&markers=color:0xFF8F00%257Clabel:A%257C32.70735640000002,-117.1564884&markers=color:0xFF8F00%257Clabel:B%257C37.62131290000001,-122.37895540000005&style=feature:landscape%7Chue:0xFFBB00%7Csaturation:43.400000000000006%7Clightness:37.599999999999994%7Cgamma:1&style=feature:road%7Chue:0xFFC200%7Csaturation:-61.8%7Clightness:45.599999999999994%7Cgamma:1&style=feature:road%7Chue:0xFF0300%7Csaturation:-100%7Clightness:51.19999999999999%7Cgamma:1&style=feature:road%7Chue:0xFF0300%7Csaturation:-100%7Clightness:52%7Cgamma:1&style=feature:water%7Chue:0x0078FF%7Csaturation:-13.200000000000003%7Clightness:2.4000000000000057%7Cgamma:1&style=feature:poi%7Chue:0x00FF6A%7Csaturation:-1.0989010989011234%7Clightness:11.200000000000017%7Cgamma:1

要查看其中一个差异,请查看参数&path=weight:12。在之后,您会在第二个字符串中看到第一个字符串中的|字符为encoded%7C。问题是此编码的网址在Google Static Maps API上获得404

$cordovaFileTransfer.download是否可以选择不对网址进行编码,或者是否存在一些参数,我应该将该网址传递给Google静态地图API,告诉它对其进行解码?

更新

我认为问题不在于编码或类似的问题,而在于编码网址的length。我尝试删除&markers param(以及之后的所有内容)并且它有效。

https://maps.googleapis.com/maps/api/staticmap?&key=AIzaSyAzijDqcmwhL7jvqZ625ZfjU-WskiuVqko&size=1000x900&path=weight:12%7Ccolor:0x037AFF%7Cenc:c%60sfEl~%60jUzAkf@%7B_@aKuhAnMhBjiAkpB%7CnB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Abt@dn@phBbeGri@nh@@dz@cKhnAvn@~z@pa@hgDpyBx%7DBxs@zgDrtA%60%7BAjn@vMrg@cRxs@rJrXfu@lYdhAgaAnrBaMlnAwu@l%5De%5Db~AdPru@mA%60vBizB~jDy%5C%60d@hi@r%5EbWfYc%5BpyBmGjjAyrJpxDwwEdsBs%7CBzaCkqEpbDsmBlpBm%7CB%60lCuqD%7CxF%7DqEn%7CImmAxlAsoBvn@qxB~m@yeBpbBcrC%60mCcbB%7CgB%7B%5ChhDaz@~aDm%60ErrWcq@%60iDmeCfqDqzDbuFkeCh~F_o@pzE_d@~eBoqBlaCujGfhGmfD%7CdEuOvcDspBtjDcf@nk@_G%7Bn@sKcQ

有趣的是,我读过Google Maps API的网址有2048字符限制。上面的第一个网址是2096个字符,第二个网址是2387个字符。我有点难过为什么第一个人在工作......

0 个答案:

没有答案