Skip to content

Commit

Permalink
fix(helper): fix a flaw for checking AMap 2.x, resolves #51
Browse files Browse the repository at this point in the history
  • Loading branch information
plainheart committed Dec 31, 2023
1 parent cc9dfff commit 26da889
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ export const COMPONENT_TYPE = 'amap'

/* global AMap */

// `AMap.version` only exists in AMap 2.x
// For AMap 1.x, it's `AMap.v`
// The version property is `AMap.v` in AMap 1.x,
// but `AMap.version` may also exist (See #51)
// In AMap 2.x, it's `AMap.version` (Not sure if `AMap.v` exists)
// use function instead of constant to allow importing the plugin before AMap is loaded
export const isAMap2X = () => AMap.version && AMap.version.split('.')[0] >= 2
export const isAMap2X = () => !AMap.v && AMap.version && AMap.version.split('.')[0] >= 2

export function v2Equal(a, b) {
return a && b && a[0] === b[0] && a[1] === b[1]
Expand Down

0 comments on commit 26da889

Please sign in to comment.