Skip to content

Commit

Permalink
Remove private and public declaration and add @internal tag (#2395)
Browse files Browse the repository at this point in the history
* remove public declaration

* remove private declaration

* prepare to add internal tag

* add @internal tag

* fix eslint comment
  • Loading branch information
fuzhenn authored Aug 8, 2024
1 parent 0de4575 commit 27fe774
Show file tree
Hide file tree
Showing 116 changed files with 1,580 additions and 334 deletions.
2 changes: 2 additions & 0 deletions src/control/Control.Attribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const layerEvents = 'addlayer removelayer setbaselayer baselayerremove';
*/
class Attribution extends Control {
options: AttributionOptionsType;
//@interlal
_attributionContainer: HTMLDivElement;

buildOn() {
Expand All @@ -65,6 +66,7 @@ class Attribution extends Control {
this.getMap().off(layerEvents, this._update, this);
}

//@interlal
_update() {
const map = this.getMap();
if (!map) {
Expand Down
8 changes: 7 additions & 1 deletion src/control/Control.Compass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ const options = {

class Compass extends Control {
options: CompassOptionsType;
//@interlal
_compass: HTMLDivElement;
//@interlal
_bearing: number;
/**
* method to build DOM of the control
Expand All @@ -45,15 +47,18 @@ class Compass extends Control {
this._rotateCompass();
}

//@interlal
_getCompass() {
const compass = createEl('div', 'maptalks-compass');
return compass;
}

//@interlal
_registerDomEvents() {
on(this._compass, 'click', this._resetView, this);
}

//@interlal
_rotateCompass() {
const b = this.getMap().getBearing().toFixed(1);
let bearing = parseFloat(b);
Expand All @@ -73,6 +78,7 @@ class Compass extends Control {
delete this._bearing;
}

//@interlal
_resetView() {
const view = { bearing: 0 };
this.getMap().animateTo(view);
Expand All @@ -96,4 +102,4 @@ export default Compass;

export type CompassOptionsType = {
position: string | DomPositionType;
} & ControlOptionsType;
} & ControlOptionsType;
10 changes: 8 additions & 2 deletions src/control/Control.LayerSwitcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,26 +71,30 @@ class LayerSwitcher extends Control {
}
}

//@interlal
_show() {
if (!hasClass(this.container, 'shown')) {
addClass(this.container, 'shown');
this._createPanel();
}
}

//@interlal
_hide(e) {
if (!this.panel.contains(e.toElement || e.relatedTarget)) {
setClass(this.container, this.options['containerClass']);
}
}

//@interlal
_createPanel() {
this.panel.innerHTML = '';
const ul = createEl('ul');
this.panel.appendChild(ul);
this._renderLayers(this.getMap(), ul);
}

//@interlal
_renderLayers(map: Map, elm: HTMLElement) {
const base = map.getBaseLayer(),
layers = map.getLayers(),
Expand Down Expand Up @@ -199,12 +203,14 @@ class LayerSwitcher extends Control {
}
}

//@interlal
_isExcluded(layer: Layer) {
const id = layer.getId(),
excludeLayers = this.options['excludeLayers'];
return !(excludeLayers.length && excludeLayers.indexOf(id) >= 0);
}

//@interlal
_renderLayer(layer, isBase?: boolean, parentChecked = true) {
const li = createEl('li', 'layer'),
label = createEl('label'),
Expand Down Expand Up @@ -238,8 +244,8 @@ class LayerSwitcher extends Control {
baseLayers = (baseLayer as any).layers;
if (baseLayers) {
for (let i = 0, len = baseLayers.length; i < len; i++) {
const _baseLayer = baseLayers[i];
_baseLayer[_baseLayer === layer ? 'show' : 'hide']();
const childLayer = baseLayers[i];
childLayer[childLayer === layer ? 'show' : 'hide']();
}
} else if (!baseLayer.isVisible()) {
baseLayer.show();
Expand Down
11 changes: 11 additions & 0 deletions src/control/Control.Overview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ class Overview extends Control {
options: OverviewOptionsType;
mapContainer: HTMLDivElement;
button: HTMLDivElement;
//@interlal
_overview: Map;
//@interlal
_perspective: Polygon;

/**
Expand Down Expand Up @@ -143,6 +145,7 @@ class Overview extends Control {
return this._overview;
}

//@interlal
_onButtonClick() {
if (!this._overview) {
this.maxmize();
Expand All @@ -152,6 +155,7 @@ class Overview extends Control {
this._updateButtonText();
}

//@interlal
_updateButtonText() {
if (this._overview) {
this.button.innerHTML = '-';
Expand All @@ -160,6 +164,7 @@ class Overview extends Control {
}
}

//@interlal
_createOverview() {
const map = this.getMap(),
dom = this.mapContainer;
Expand Down Expand Up @@ -190,6 +195,7 @@ class Overview extends Control {
this.fire('load');
}

//@interlal
_getOverviewZoom() {
const map = this.getMap(),
zoom = map.getZoom(),
Expand All @@ -213,12 +219,14 @@ class Overview extends Control {
}


//@interlal
_onDragEnd() {
const center = this._perspective.getCenter();
this._overview.setCenter(center);
this.getMap().panTo(center);
}

//@interlal
_getPerspectiveCoords() {
const map = this.getMap();
const projection = map.getProjection();
Expand All @@ -232,6 +240,7 @@ class Overview extends Control {
});
}

//@interlal
_update() {
if (!this._overview) {
return;
Expand All @@ -243,6 +252,7 @@ class Overview extends Control {
this._overview.setCenterAndZoom(this.getMap().getCenter(), this._getOverviewZoom());
}

//@interlal
_updateSpatialReference() {
if (!this._overview) {
return;
Expand All @@ -252,6 +262,7 @@ class Overview extends Control {
this._overview.setSpatialReference(spatialRef);
}

//@interlal
_updateBaseLayer() {
if (!this._overview) {
return;
Expand Down
7 changes: 7 additions & 0 deletions src/control/Control.Panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ const options: PanelOptionsType = {
class Panel extends Control {
draggable: DragHandler;
options: PanelOptionsType;
//@interlal
_startPos: Point;
//@interlal
_startPosition: DomPositionType;

/**
Expand Down Expand Up @@ -146,6 +148,7 @@ class Panel extends Control {
return this.options['content'];
}

//@interlal
_cancelOn(domEvent) {
const target = domEvent.srcElement || domEvent.target,
tagName = target.tagName.toLowerCase();
Expand All @@ -159,6 +162,7 @@ class Panel extends Control {
return false;
}

//@interlal
_onDragStart(param) {
this._startPos = param['mousePos'];
this._startPosition = extend({}, this.getPosition());
Expand All @@ -174,6 +178,7 @@ class Panel extends Control {
this.fire('dragstart', param);
}

//@interlal
_onDragging(param) {
const pos = param['mousePos'];
const offset = pos.sub(this._startPos);
Expand Down Expand Up @@ -205,6 +210,7 @@ class Panel extends Control {
this.fire('dragging', param);
}

//@interlal
_onDragEnd(param) {
delete this._startPos;
delete this._startPosition;
Expand All @@ -224,6 +230,7 @@ class Panel extends Control {
* Get the connect points of panel for connector lines.
* @private
*/
//@interlal
_getConnectPoints() {
const map = this.getMap();
const containerPoint = this.getContainerPoint();
Expand Down
5 changes: 5 additions & 0 deletions src/control/Control.Reset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ const options: ResetOptionsType = {
};

class Reset extends Control {
//@interlal
_reset: HTMLDivElement;
//@interlal
_view: MapViewType;
options: ResetOptionsType;
/**
Expand All @@ -48,11 +50,13 @@ class Reset extends Control {
this._view = view;
}

//@interlal
_getReset() {
const reset = createEl('div', 'maptalks-reset');
return reset as HTMLDivElement;
}

//@interlal
_registerDomEvents() {
on(this._reset, 'click', this._resetView, this);
}
Expand All @@ -62,6 +66,7 @@ class Reset extends Control {
delete this._view;
}

//@interlal
_resetView() {
this.getMap().setView(this._view);
}
Expand Down
10 changes: 10 additions & 0 deletions src/control/Control.Scale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@ const options: ScaleOptionsType = {
const EVENTS_TO_LISTEN = 'zoomend moving moveend';

class Scale extends Control {
//@interlal
_scaleContainer: HTMLDivElement;
//@interlal
_mScale: HTMLDivElement;
//@interlal
_iScale: HTMLDivElement;
options: ScaleOptionsType;

Expand All @@ -64,6 +67,7 @@ class Scale extends Control {
this.getMap().off(EVENTS_TO_LISTEN, this._update, this);
}

//@interlal
_addScales() {
const css = 'border: 2px solid #000000;border-top: none;line-height: 1.1;padding: 0px;' +
'color: #000000;font-size: 11px;text-align:center;white-space: nowrap;overflow: hidden' +
Expand All @@ -76,12 +80,14 @@ class Scale extends Control {
}
}

//@interlal
_update() {
const map = this._map;
const maxMeters = map.pixelToDistance(this.options['maxWidth'], 0);
this._updateScales(maxMeters);
}

//@interlal
_updateScales(maxMeters: number) {
if (this.options['metric'] && maxMeters) {
this._updateMetric(maxMeters);
Expand All @@ -91,13 +97,15 @@ class Scale extends Control {
}
}

//@interlal
_updateMetric(maxMeters: number) {
const meters = this._getRoundNum(maxMeters),
label = meters < 1000 ? meters + ' m' : (meters / 1000) + ' km';

this._updateScale(this._mScale, label, meters / maxMeters);
}

//@interlal
_updateImperial(maxMeters: number) {
const maxFeet = maxMeters * 3.2808399;
let maxMiles, miles, feet;
Expand All @@ -113,11 +121,13 @@ class Scale extends Control {
}
}

//@interlal
_updateScale(scale: HTMLDivElement, text: string, ratio: number) {
scale['style']['width'] = Math.round(this.options['maxWidth'] * ratio) + 'px';
scale['innerHTML'] = text;
}

//@interlal
_getRoundNum(num: number) {
const pow10 = Math.pow(10, (Math.floor(num) + '').length - 1);
let d = num / pow10;
Expand Down
2 changes: 2 additions & 0 deletions src/control/Control.Toolbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ class Toolbar extends Control {
return dom;
}

//@interlal
_createDropMenu(index: number) {
const me = this;

Expand Down Expand Up @@ -180,6 +181,7 @@ class Toolbar extends Control {
return menuDom;
}

//@interlal
_getItems() {
return this.options['items'] || [];
}
Expand Down
Loading

0 comments on commit 27fe774

Please sign in to comment.