Skip to content

Commit

Permalink
[fix] 修改 mip-map 将 BMap 挂载到沙盒对象上的方法 (#598)
Browse files Browse the repository at this point in the history
* 修改 mip-map 将 BMap 挂载到沙盒对象上的方法

* 将 map 常量挂载到BMap.CONSTANTS 上面去

* 尽量少改动原有逻辑
  • Loading branch information
clark-t authored Apr 15, 2019
1 parent 3b2787a commit 4bd98a9
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions components/mip-map/mip-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,14 @@ export default class MIPMap extends CustomElement {
window.BMap = {}
window.BMap._insertScript = new Promise(resolve => {
window._initBaiduMap = () => {
// 把百度地图的参数挂到 BMap.CONSTANTS 上
window.BMap.CONSTANTS = Object.keys(window)
.filter(key => key.indexOf('BMAP_') === 0)
.reduce((obj, key) => {
obj[key] = window[key]
return obj
}, {})

resolve(window.BMap)
window.document.body.removeChild(script)
window.BMap._insertScript = null
Expand All @@ -152,12 +160,7 @@ export default class MIPMap extends CustomElement {
let BMap = window.BMap

// BMap注入沙盒
Object.defineProperty(sandbox, 'BMap', {
value: BMap,
writable: false,
enumerable: true,
configurable: true
})
sandbox.BMap = BMap

// 派发事件
viewer.eventAction.execute('loaded', this.element, {})
Expand Down

0 comments on commit 4bd98a9

Please sign in to comment.