Skip to content

Commit

Permalink
Fix scale control default parameters (maplibre#4002)
Browse files Browse the repository at this point in the history
Before this CL, the following would generate an error:

```ts
const scaleCtrl = new ScaleControl():
```

because options is not marked as optional.

Co-authored-by: Harel M <[email protected]>
  • Loading branch information
vicb and HarelM authored Apr 15, 2024
1 parent ffd38b6 commit d76c044
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
### 🐞 Bug fixes
- Fix different unwanted panning changes at the end of a panning motion, that happen on a large screen ([#3935](https://github.com/maplibre/maplibre-gl-js/issues/3935))
- Fix image sources not being marked as loaded on error
- Fix ScaleControl options should be optional. ([#4002](https://github.com/maplibre/maplibre-gl-js/pull/4002))
- Fix race condition in SourceCache that makes unit tests unstable. Eliminate a redundant 'visibility' event fired from Style class. ([#3992](https://github.com/maplibre/maplibre-gl-js/issues/3992))


## 4.1.2

### ✨ Features and improvements
Expand Down
5 changes: 2 additions & 3 deletions src/ui/control/scale_control.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {DOM} from '../../util/dom';
import {extend} from '../../util/util';

import type {Map} from '../map';
import type {ControlPosition, IControl} from './control';
Expand Down Expand Up @@ -51,8 +50,8 @@ export class ScaleControl implements IControl {
_container: HTMLElement;
options: ScaleControlOptions;

constructor(options: ScaleControlOptions) {
this.options = extend({}, defaultOptions, options);
constructor(options?: ScaleControlOptions) {
this.options = {...defaultOptions, ...options};
}

getDefaultPosition(): ControlPosition {
Expand Down

0 comments on commit d76c044

Please sign in to comment.