Skip to content

Commit

Permalink
Improve Source#updateSource to use setTiles function if available
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelroth committed Feb 14, 2024
1 parent d10dc62 commit 8739751
Showing 1 changed file with 4 additions and 13 deletions.
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

0 comments on commit 8739751

Please sign in to comment.