Skip to content

Commit

Permalink
Merge pull request #680 from alex3165/bugfix/image-add-style-change
Browse files Browse the repository at this point in the history
Fixing images on style change
  • Loading branch information
alex3165 authored Jan 23, 2019
2 parents 03a34c6 + d32f764 commit 6f17bac
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/jest/util.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const getMapMock = (override?: { [key: string]: any }) => ({
setLayerZoomRange: jest.fn(),
getLayer: jest.fn(),
addImage: jest.fn(),
hasImage: jest.fn(),
getSource: jest.fn().mockReturnValue({ setData: jest.fn() }),
project: jest.fn(),
...override
Expand Down
8 changes: 5 additions & 3 deletions src/layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,11 @@ export default class Layer extends React.Component<Props> {

if (images) {
const normalizedImages = !Array.isArray(images[0]) ? [images] : images;
(normalizedImages as ImageDefinitionWithOptions[]).forEach(image => {
map.addImage(image[0], image[1], image[2]);
});
(normalizedImages as ImageDefinitionWithOptions[])
.filter(image => !map.hasImage(image[0]))
.forEach(image => {
map.addImage(image[0], image[1], image[2]);
});
}

if (!sourceId && !map.getSource(id)) {
Expand Down

0 comments on commit 6f17bac

Please sign in to comment.