antvis / L7

🌎 Large-scale WebGL-powered Geospatial Data Visualization analysis engine.
https://l7.antv.antgroup.com
MIT License
3.67k stars 636 forks source link

在高德地图作为底图时,设置的主题不生效,发现高德需要传入密钥,不知道是不是因为这个,但是不知道在antv里面如何传入高德密钥 #2290

Closed HFY-aa closed 9 months ago

HFY-aa commented 9 months ago
github-actions[bot] commented 9 months ago

hi @HFY-aa, welcome!

github-actions[bot] commented 9 months ago

Hi @HFY-aa, Please star this repo if you find it useful! Thanks :star:! 你好 @HFY-aa。如果该仓库对你有用,可以 star 一下,感谢你的 :star:!

foxii-cn commented 9 months ago

参见 JS API 安全密钥使用

Vue组合式API+TypeScript示例

const scene = shallowRef<Scene>()
onMounted(() => {
  scene.value = new L7.Scene({
    id: 'map',
    map: new GaodeMap({
      pitch: 0,
      zoom: 14,
      token: '[Key]',                     // 这
    }),
  })
})
useMapSecurityConfig()
declare const window: {
  _AMapSecurityConfig?: {
    serviceHost?: string         // 代理服务器转发
    securityJsCode?: string      // 明文方式
  }
} & Window
function useMapSecurityConfig() {
  window._AMapSecurityConfig = {
    securityJsCode: '[安全密钥]',         // 和这
  } as const
  onScopeDispose(() => delete window._AMapSecurityConfig)
}