目前我正在开发一个项目,我需要将折线存储在数据库中,然后将其显示在 map 上。 我正在使用 getPath() 方法来获取坐标。但它给出了“未定义”的输出。 代码用JS编写,AJAX调用用于存储数据。 网页位于codeigniter框架中。
功能是:
函数submitInformationForm(){
var path = [];
path = poly.getPath();
var pathLength = path.length;
var _b = path.j;
var str = [];
str = '';
if(pathLength!=0){
for(var i=0; i<pathLength; i++){
var point = _b[i].H +','+ _b[i].L;
str = str + point;
if(i < (pathLength-1)){
str = str+'-';
}
}
if(info_name && info_description && color && str!=''){
$.ajax({
url: '<?php echo site_url('admin/show_map/fill_information');?>',
type: 'post',
data:{
'name' : info_name,
'color' : color,
'latlngs' : str,
},
success: function(resp){
window.location.reload();
}
});
}else{
alert("All fields are mendatory...");
}
}
}
最佳答案
关于javascript - 如何将折线保存到数据库中?使用谷歌地图和JS?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33773385/