【发布时间】:2018-04-01 16:41:57
【问题描述】:
重写问题以使其对其他人有用: 在使用 google maps api encodePoly 对我上传到数据库的折线进行编码后。当我下载、解码和显示时,它显示不正确。
我学到的是,我需要在对路径进行编码之后以及在发送到 POST 到数据库之前立即将 \ 替换为 \。
如果你下载,解码然后替换它为时已晚。现在说得通了。
function transferRteData(runPath,map) {
var encodedPath = google.maps.geometry.encoding.encodePath(runPath.getPath());
encodedPath=encodedPath.replace(/\\/g, "\\\\");
var data = {'encodedPath':encodedPath,};
$.getJSON("{% url 'getfitmappedrte-view' %}", data, function(response){
if(response === 'success'){ alert('Yay!'); }
else{ alert('Error! :('); }
});
} //Close Transfer Data
【问题讨论】:
-
什么是
encodedPath?请提供一个 minimal reproducible example 来证明该问题。
标签: javascript api google-maps