Skip to content

Commit

Permalink
Merge pull request #166 from 2ming/master
Browse files Browse the repository at this point in the history
设置百度地图版本
  • Loading branch information
西瓜 authored Jan 23, 2018
2 parents f92c2ae + 6b4bf01 commit 9891cb6
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions examples/pages/bmap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export default {
return {
chartSettings: {
key: 'oBvDtR6nzWtVchkY4cLHtnah1VVZQKRK',
v: '3.0',
bmap: {
center: [120, 30],
zoom: 14,
Expand Down
3 changes: 2 additions & 1 deletion src/packages/bmap/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ import { getBmap } from '../../utils'
export const bmap = (_, __, settings) => {
const {
key,
v = '2.0',
bmap
} = settings
if (!key) console.warn('settings.key must be a string.')

return getBmap(key).then(_ => {
return getBmap(key, v).then(_ => {
return { bmap }
})
}
3 changes: 2 additions & 1 deletion src/packages/heatmap/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ export const heatmap = (columns, rows, settings, status) => {
bmap,
geo,
key,
v = '2.0',
position,
positionJsonLink,
beforeRegisterMap,
Expand Down Expand Up @@ -182,7 +183,7 @@ export const heatmap = (columns, rows, settings, status) => {
if (type === 'bmap') {
Object.assign(options.series[0], { coordinateSystem: 'bmap', pointSize, blurSize })

return getBmap(key).then(_ => {
return getBmap(key, v).then(_ => {
return Object.assign({ bmap }, options)
})
} else if (type === 'map') {
Expand Down
4 changes: 2 additions & 2 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@ export const getMapJSON = (position, positionJsonLink) => {

let mapPromise = null

export const getBmap = (key) => {
export const getBmap = (key, v) => {
if (!mapPromise) {
mapPromise = new Promise((resolve, reject) => {
const callbackName = `bmap${Date.now()}`
window[callbackName] = resolve
const script = document.createElement('script')
script.src = [
'https://api.map.baidu.com/api?v=2.0',
`https://api.map.baidu.com/api?v=${v}`,
`ak=${key}`,
`callback=${callbackName}`
].join('&')
Expand Down

0 comments on commit 9891cb6

Please sign in to comment.