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

Improves Source#updateSource to use setTiles function if available #2355

Merged
merged 2 commits into from
Dec 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 4 additions & 13 deletions src/components/source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,10 @@ function updateSource<SourceT extends ISource>(
});
} else if ('setCoordinates' in source && changedKeyCount === 1 && changedKey === 'coordinates') {
source.setCoordinates((props as ImageSourceRaw).coordinates);
} else if ('setUrl' in source) {
// Added in 1.12.0:
// vectorTileSource.setTiles
// vectorTileSource.setUrl
switch (changedKey) {
case 'url':
source.setUrl((props as VectorSourceRaw).url);
break;
case 'tiles':
source.setTiles((props as VectorSourceRaw).tiles);
break;
default:
}
} else if ('setUrl' in source && changedKey === 'url') {
source.setUrl((props as VectorSourceRaw).url);
} else if ('setTiles' in source && changedKey === 'tiles') {
source.setTiles((props as VectorSourceRaw).tiles);
} else {
// eslint-disable-next-line
console.warn(`Unable to update <Source> prop: ${changedKey}`);
Expand Down
Loading