1、原因:
【1】: 传入的坐标格式不是数组格式, 例如: position: {116.406315,39.908775}
【2】: 传入的坐标不是number, 有可能是字符串, 例如:position: [“116.406315”, “39.908775” ],
【3】: 传入的坐标就是一个空值 :[ ]
【4】:传入的坐标不是先经度lng再纬度lat(不懂经纬度的百度搜索一下)
总之,就是数据处理错了
2、处理数据:
paths.forEach(v => {
position.push([v.lng, v.lat])//[116.406315, 39.908775]
});
position: [“116.406315”, “39.908775”]=>position.map(Number)//map会生成新数组,将数组转数字[116.406315, 39.908775]
3、处理的到数据案例:
position=[
[116.478935, 39.997761],
[116.478939, 39.997825],
]
不处理成这样的数据高德地图是解析不出来的