提交 f2bea036 编写于 作者: 惨白的生物 提交者: Joker

update docs/api/location/map.md.

Object.assign(marker, p) 改变的原对象 marker , 循环结束以后拿到的 markers 里面是重复的同一条数据,此时 addMarkers 会产生一些错误
上级 67312039
...@@ -333,18 +333,17 @@ mapContext ...@@ -333,18 +333,17 @@ mapContext
const markers = [] const markers = []
positions.forEach((p, i) => { positions.forEach((p, i) => {
const newMarker = Object.assign(marker, p) const newMarker = Object.assign({},marker, p)
newMarker.id = i + 1 newMarker.id = i + 1
newMarker.label.content = `label ${i + 1}` newMarker.label.content = `label ${i + 1}`
markers.push(newMarker) markers.push(newMarker)
})
this._mapContext.addMarkers({ this._mapContext.addMarkers({
markers, markers,
clear: false, clear: false,
complete(res) { complete(res) {
console.log('addMarkers', res) console.log('addMarkers', res)
} }
})
}) })
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册