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

fix VectorLayer types and controls types #2434

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
9 changes: 5 additions & 4 deletions src/control/Control.Attribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ const layerEvents = 'addlayer removelayer setbaselayer baselayerremove';
* attribution: '&copy; <a href="http://osm.org">OpenStreetMap</a> contributors, &copy; <a href="https://carto.com/">CARTO</a>'
* }));
*/
class Attribution extends Control {
options: AttributionOptionsType;
class Attribution extends Control<AttributionOptionsTypeSpec> {
//@internal
_attributionContainer: HTMLDivElement;

Expand Down Expand Up @@ -130,7 +129,9 @@ Map.addOnLoadHook(function () {

export default Attribution;

export type AttributionOptionsType = {
export type AttributionOptionsTypeSpec = {
content?: string | HTMLElement;
custom?: boolean;
} & ControlOptionsType;
};

export type AttributionOptionsType = AttributionOptionsTypeSpec & ControlOptionsType;
9 changes: 5 additions & 4 deletions src/control/Control.Compass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ const options = {
}
};

class Compass extends Control {
options: CompassOptionsType;
class Compass extends Control<CompassOptionsTypeSpec> {
//@internal
_compass: HTMLDivElement;
//@internal
Expand Down Expand Up @@ -100,6 +99,8 @@ Map.addOnLoadHook(function () {

export default Compass;

export type CompassOptionsType = {
export type CompassOptionsTypeSpec = {
position: string | DomPositionType;
} & ControlOptionsType;
};

export type CompassOptionsType = CompassOptionsTypeSpec & ControlOptionsType;
9 changes: 5 additions & 4 deletions src/control/Control.LayerSwitcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ const options: LayerSwitcherOptionsType = {
* position : {'top': '0', 'right': '0'}
* }).addTo(map);
*/
class LayerSwitcher extends Control {
options: LayerSwitcherOptionsType;
class LayerSwitcher extends Control<LayerSwitcherOptionsTypeSpec> {
container: HTMLDivElement;
panel: HTMLDivElement;
button: HTMLButtonElement;
Expand Down Expand Up @@ -279,9 +278,11 @@ Map.addOnLoadHook(function () {

export default LayerSwitcher;

export type LayerSwitcherOptionsType = {
export type LayerSwitcherOptionsTypeSpec = {
baseTitle?: string;
overlayTitle?: string;
containerClass?: string;
excludeLayers?: Array<string>;
} & ControlOptionsType;
};

export type LayerSwitcherOptionsType = LayerSwitcherOptionsTypeSpec & ControlOptionsType;
12 changes: 5 additions & 7 deletions src/control/Control.Nav.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
import Map from '../map/Map';
import Control, { ControlOptionsType, DomPositionType } from './Control';


const options: NavOptionsType = {
'position': 'top-left'
};


export default class Nav extends Control {

export default class Nav extends Control<NavOptionsTypeSpec> {
buildOn() {
return null;
}

}

Nav.mergeOptions(options);
Expand All @@ -28,6 +24,8 @@ Map.addOnLoadHook(function () {
}
});

export type NavOptionsType = {
export type NavOptionsTypeSpec = {
position: string | DomPositionType;
} & ControlOptionsType;
};

export type NavOptionsType = NavOptionsTypeSpec & ControlOptionsType;
10 changes: 6 additions & 4 deletions src/control/Control.Overview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ const options: OverviewOptionsType = {
* size: [300, 200]
* }).addTo(map);
*/
class Overview extends Control {
options: OverviewOptionsType;
class Overview extends Control<OverviewOptionsTypeSpec> {
mapContainer: HTMLDivElement;
button: HTMLDivElement;
//@internal
Expand Down Expand Up @@ -324,7 +323,8 @@ Map.addOnLoadHook(function () {
});

export default Overview;
export type OverviewOptionsType = {

export type OverviewOptionsTypeSpec = {
level?: number;
size?: Array<number>;
maximize?: boolean;
Expand All @@ -336,4 +336,6 @@ export type OverviewOptionsType = {
};
containerClass?: string;
buttonClass?: string;
} & ControlOptionsType;
};

export type OverviewOptionsType = OverviewOptionsTypeSpec & ControlOptionsType;
Loading