Decoded polyline needs escaping of '/' chars
See original GitHub issueDecoding the following Encoded polyline yields incorrect data (A number of lat,lng pairs were missing)
z``mEm~zv[rNgaALmc@kFg~AMae@zV_gCZqR{y@}F_u@wJ_^_DkN{@cHrkBfd@znA_X|uCsReBcF|j@{fAo\cNsOwIaBqJnFwIge@rFgeAyrBaTsHvdAyJa@cFtj@}GQxt@fhCq@zQp@tEpDxEg@pCPDFvDgA|CiYza@sBrSaS~XMG_ADiMQwBbHOnFmBtS~PnCiKhqAn{@_AeAtHdtAfYhf@mEtGeGb[_k@zA_o@aKwm@nKg@rRsGl\fJvQxJz@uDhCsEpIyChCoB|E{OcF}C@oIfDiTnBcQlCqYlAkHnOe_@jJc^
I discovered I could recover the missing [lat,lngs] by double escaping the ‘\’ characters. The complete and correct encoded polyline becomes:
z``mEm~zv[rNgaALmc@kFg~AMae@zV_gCZqR{y@}F_u@wJ_^_DkN{@cHrkBfd@znA_X|uCsReBcF|j@{fAo\\cNsOwIaBqJnFwIge@rFgeAyrBaTsHvdAyJa@cFtj@}GQxt@fhCq@zQp@tEpDxEg@pCPDFvDgA|CiYza@sBrSaS~XMG_ADiMQwBbHOnFmBtS~PnCiKhqAn{@_AeAtHdtAfYhf@mEtGeGb[_k@zA_o@aKwm@nKg@rRsGl\\fJvQxJz@uDhCsEpIyChCoB|E{OcF}C@oIfDiTnBcQlCqYlAkHnOe_@jJc^
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (3 by maintainers)

Top Related StackOverflow Question
I was calling polyline.decode() manually from the NPM console (following one of many suggestions found online for decoding polylines).
So yes, while you are technically correct there is still a use case where someone runs polyline.decode(‘xy/z’) directly from the NPM console and it will omit numerous pairs of points.
You’re conflating or confusing the in-memory representation of a string with representation of a string literal in source code text. polyline operates on in-memory string representation, where there is no notion of escaping, and no need to escape special characters. You only need to escape “manually” if you are passing polyline data as a string literal which is hard-coded into the JavaScript source. In most cases, you pass a polyline string obtained from some other web service or data source.