为什么我的map组件中polyline不显示?
.wxml: <view class="map">
<map
id="route_map"
latitude="{{latitude}}"
longitude="{{longitude}}"
style="height: 100%; width: 100%;"
polyline="{{polyline}}"
show-location="true">
</map>
</view>
数据是从数据库中获取到的,下面是处理过程,打印信息。 .js: //参数定义
data: {
latitude: 39.7850456237793,
longitude: 116.49617767333984,
polyline: {
points:[
{Latitude: 39.7850456237793, Longitude: 116.49617767333984},
{Latitude: 39.78499984741211, Longitude: 116.49617767333984},
{Latitude: 39.78501892089844, Longitude: 116.49617767333984},
{Latitude: 39.78501510620117, Longitude: 116.49617767333984},
{Latitude: 39.78501892089844, Longitude: 116.49617767333984},
{Latitude: 39.785003662109375, Longitude: 116.49617767333984},
{Latitude: 39.785003662109375, Longitude: 116.4961929321289},
{Latitude: 39.78498458862305, Longitude: 116.49620819091797},
{Latitude: 39.785037994384766, Longitude: 116.49617004394531},
{Latitude: 39.785011291503906, Longitude: 116.49617767333984},
{Latitude: 39.78500747680664, Longitude: 116.49617767333984},
{Latitude: 39.78498077392578, Longitude: 116.4961929321289},
{Latitude: 39.78500747680664, Longitude: 116.49617767333984},
{Latitude: 39.78501510620117, Longitude: 116.49617767333984},
{Latitude: 39.78501510620117, Longitude: 116.4961929321289},
{Latitude: 39.785125732421875, Longitude: 116.49617004394531},
{Latitude: 39.7850227355957, Longitude: 116.4961929321289},
{Latitude: 39.78496551513672, Longitude: 116.49620819091797},
{Latitude: 39.78501510620117, Longitude: 116.4961929321289},
{Latitude: 39.78501510620117, Longitude: 116.4961929321289},
{Latitude: 39.78501510620117, Longitude: 116.4961929321289},
{Latitude: 39.78504180908203, Longitude: 116.4961929321289},
{Latitude: 39.78499984741211, Longitude: 116.4961929321289},
{Latitude: 39.785003662109375, Longitude: 116.49620819091797},
{Latitude: 39.7850341796875, Longitude: 116.49617767333984},
{Latitude: 39.78496551513672, Longitude: 116.49620819091797},
{Latitude: 39.78495407104492, Longitude: 116.49620819091797},
{Latitude: 39.784976959228516, Longitude: 116.49620819091797},
{Latitude: 39.78498458862305, Longitude: 116.49620819091797},
{Latitude: 39.78496551513672, Longitude: 116.49620819091797},
],
},
},
//数据获取到后处理过程
success: function (res) { //成功获取到值,返回一个 res 对象。
console.log(res);
console.log("数据长度:", res.data.length)
//判断是否没有对应的数据
var data_len = res.data.length;
if (data_len == 0) {
wx.showToast({
title: '未查到定位信息',
})
return
} else {
wx.showToast({
title: '查询成功',
icon: 'success'
})
}
_this.setData({
// 将路线的起点设置为地图中心点
latitude:res.data[0].latitude,
longitude:res.data[0].longitude,
// 绘制路线
polyline: {
points: res.data,
color: '#58c16c',
width: 6,
borderColor: '#2f693c',
borderWidth: 1
}
})
console.log("获取到的坐标:",_this.data.polyline)
},
fail: function () { //没有获取到值,说明这中间出问题了。
console.log("获取失败");
}
})
//打印的调试信息 [图片] [图片][图片] 代码片段:https://developers.weixin.qq.com/s/tmfpabmK7VRz