antvis / antvis/LarkMap

🥰 图片/字体资源注册异步方式

Open
#164 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
87
Forks
34
PR merge metrics
No merged PRs in 30d

Description

### 💻 图片/字体资源统一注册使用方式

### 🏞 cene.addImage 是异步的,图层可能先渲染导致没有出来,当下解决的方案 await scene.addImage 完成再渲染图层

```tsx

import { LarkMap } from '@antv/larkmap';

export default () => {
const [loadedImages, setLoadedImages] = useState(false);
const onSceneLoaded = (scene: Scene) => {
scene.addImage('name', url).then(() => {
setLoadedImages(true);
})
console.log(scene);
};

return (

{ loadedImages && }

);
};
```

### 🧐 What does the proposed API look like

```tsx

import { LarkMap } from '@antv/larkmap';

const images = [
{ id: '01', image: 'https://gw.alipayobjects.com/zos/basement_prod/604b5e7f-309e-40db-b95b-4fac746c5153.svg' },
{ id: '02', image: 'https://gw.alipayobjects.com/zos/basement_prod/30580bc9-506f-4438-8c1a-744e082054ec.svg' },
{ id: '03', image: 'https://gw.alipayobjects.com/zos/basement_prod/7aa1f460-9f9f-499f-afdf-13424aa26bbf.svg' },
];

export default () => {
const onSceneLoaded = (scene: Scene) => {
console.log(scene);
};

return (



);
};
```

### 🚑 Any additional
统一管理缺点就是加载资源失败,还是需要 try catch 不能让所有图层出不来

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at the LarkMap component's onSceneLoaded entry point and trace how scene.addImage promises are handled. Compare that lifecycle with the proposed registerImages prop; done should cover registration before dependent layers render and the stated failure behavior without blocking unrelated layers.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
data-visualization, frontend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.