1、問題:微信小程序中使用map組件中的polyline屬性劃線,發(fā)現(xiàn)編譯器和蘋果機型都顯示,只有奇葩的安卓能看到,后來看了文檔才發(fā)現(xiàn)polyline數(shù)組中的一個color屬性的表達需要寫成16進制(這種情況根本就無法想象到問題會出在這,整得自己只能看文檔說明),起初還以為map是原生組件,層級為最高,不能被覆蓋,整得自己陷在思維誤區(qū)里,最關鍵的是這尼瑪是之前同事的代碼,讓我維護。氣不打一處,想拉他回來打一頓...
2、初始問題代碼
var polyline = [{
points: temp,
color: "red",
width: 2,
dottedLine: true
}];
3、微信文檔地址,圖片如下:

1570778003(1).jpg
4、改回后編譯器里的效果,蘋果也沒問題的,這里只上編譯器的效果

image.png
5、自己測試代碼
wxml代碼
<!--pages/map/map.wxml-->
<map class="navi_map" longitude="102.67484140406796" latitude="25.03682953251695" scale="100" include-points='{{points}}' polyline="{{polyline}}" ></map>
wxss代碼
/* pages/map/map.wxss */
.navi_map{
width: 100%;
height: 667px;
}
js代碼
// pages/map/map.js
Page({
/**
* 頁面的初始數(shù)據(jù)
*/
data: {
longitude: '',
latitude:'',
points: [],
polyline: []
},
/**
* 生命周期函數(shù)--監(jiān)聽頁面加載
*/
onLoad: function (options) {
var lat = 25.03682953251695, lng = 102.67484140406796;
var temp = [{
latitude: 25.03682953251695,
longitude: 102.67484140406796
},
{
latitude: 25.036132223872958,
longitude: 102.67386832053477
},
{
latitude: 25.035328234772695,
longitude: 102.67441722093537
},
{
latitude: 25.03587706184719,
longitude: 102.67548958617391
},
{
latitude: 25.03682953251695,
longitude: 102.67484140406796
},
]
var polyline = [{
points: temp,
color: "#ff0000",
width: 2,
dottedLine: true
}];
this.setData({
longitude:lng,
latitude:lat,
polyline:polyline,
points:temp
})
},
})