Skip to content

Commit

Permalink
fix: check if getResolutionForZoom can be called in feature styler (m…
Browse files Browse the repository at this point in the history
  • Loading branch information
stew-ro committed Apr 8, 2020
1 parent a6667e9 commit ce19588
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/react/components/common/imageMap/imageMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,11 @@ export class ImageMap extends React.Component<IImageMapProps> {
}

public getResolutionForZoom = (zoom: number) => {
return this.map.getView().getResolutionForZoom(zoom);
if (this.map && this.map.getView()) {
return this.map.getView().getResolutionForZoom(zoom);
} else {
return null;
}
}

/**
Expand Down
6 changes: 4 additions & 2 deletions src/react/components/pages/editorPage/canvas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,8 @@ export default class Canvas extends React.Component<ICanvasProps, ICanvasState>
return new Style({
image: new Icon({
opacity: 0.3,
scale: this.imageMap.getResolutionForZoom(3) / resolution,
scale: this.imageMap && this.imageMap.getResolutionForZoom(3) ?
this.imageMap.getResolutionForZoom(3) / resolution : 1,
anchor: [.95, 0.15],
anchorXUnits: "fraction",
anchorYUnits: "fraction",
Expand All @@ -713,7 +714,8 @@ export default class Canvas extends React.Component<ICanvasProps, ICanvasState>
return new Style({
image: new Icon({
opacity: 1,
scale: this.imageMap.getResolutionForZoom(3) / resolution,
scale: this.imageMap && this.imageMap.getResolutionForZoom(3) ?
this.imageMap.getResolutionForZoom(3) / resolution : 1,
anchor: [.95, 0.15],
anchorXUnits: "fraction",
anchorYUnits: "fraction",
Expand Down

0 comments on commit ce19588

Please sign in to comment.