Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

高德地图加载 scene.on('click', (ev) => {}) 为什么报错误? #1855

Closed
DreamNO1 opened this issue Sep 12, 2023 · 3 comments
Closed
Assignees

Comments

@DreamNO1
Copy link

1.方法 scene.on('click', (ev) => {
console.log(ev);
console.log('scene.on click');
});
2. error:
AMapBaseService.js:178 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'on')
at AMapService.on (AMapBaseService.js:178:1)
at Scene.on (index.js:457:1)
at Proxy.InstallMap (GaoDeMapChoropleth.vue:100:1)
at Proxy.mounted (GaoDeMapChoropleth.vue:20:1)
at eval (runtime-core.esm-bundler.js:2675:1)
at callWithErrorHandling (runtime-core.esm-bundler.js:158:1)
at callWithAsyncErrorHandling (runtime-core.esm-bundler.js:166:1)
at hook.__weh.hook.__weh (runtime-core.esm-bundler.js:2655:1)
at flushPostFlushCbs (runtime-core.esm-bundler.js:325:1)
at flushJobs (runtime-core.esm-bundler.js:363:1)

@DreamNO1
Copy link
Author

const scene = new Scene({
id: 'map',
map: new GaodeMap({
style: 'normal',
center: [120.19382669582967, 30.258134],
zoom: 3,
}),
});

scene.on('loaded', () => {}) 是可以正常加载的,地图也是可以正常加载的

@lzxue
Copy link
Contributor

lzxue commented Sep 12, 2023

地图没初始化完成,click 放到 loaded 里面去监听,

@DreamNO1
Copy link
Author

好的,感谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants