Skip to content

Commit 2b319ae

Browse files
committed
[Maps] Added options to disable zoom, hide tool tips, widgets/overlays in embeddable maps (#50663)
* added options to disable zoom, hide tool tips, widgets/overlays in embeddable maps * revert panel changes * added disable interactive * remove redundant code * update redux state and removed widget over lay hiding * update readme with added map props
1 parent 02cd282 commit 2b319ae

File tree

9 files changed

+265
-194
lines changed

9 files changed

+265
-194
lines changed

x-pack/legacy/plugins/maps/public/actions/map_actions.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ export const SET_TOOLTIP_STATE = 'SET_TOOLTIP_STATE';
6767
export const UPDATE_DRAW_STATE = 'UPDATE_DRAW_STATE';
6868
export const SET_SCROLL_ZOOM = 'SET_SCROLL_ZOOM';
6969
export const SET_MAP_INIT_ERROR = 'SET_MAP_INIT_ERROR';
70+
export const SET_INTERACTIVE = 'SET_INTERACTIVE';
71+
export const DISABLE_TOOLTIP_CONTROL = 'DISABLE_TOOLTIP_CONTROL';
72+
export const HIDE_TOOLBAR_OVERLAY = 'HIDE_TOOLBAR_OVERLAY';
7073

7174
function getLayerLoadingCallbacks(dispatch, layerId) {
7275
return {
@@ -814,3 +817,15 @@ export function updateDrawState(drawState) {
814817
});
815818
};
816819
}
820+
821+
export function disableInteractive() {
822+
return { type: SET_INTERACTIVE, disableInteractive: true };
823+
}
824+
825+
export function disableTooltipControl() {
826+
return { type: DISABLE_TOOLTIP_CONTROL, disableTooltipControl: true };
827+
}
828+
829+
export function hideToolbarOverlay() {
830+
return { type: HIDE_TOOLBAR_OVERLAY, hideToolbarOverlay: true };
831+
}

x-pack/legacy/plugins/maps/public/connected_components/gis_map/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ import {
1414
areLayersLoaded,
1515
getRefreshConfig,
1616
getMapInitError,
17-
getQueryableUniqueIndexPatternIds
17+
getQueryableUniqueIndexPatternIds,
18+
isToolbarOverlayHidden,
1819
} from '../../selectors/map_selectors';
1920

2021
function mapStateToProps(state = {}) {
@@ -28,6 +29,7 @@ function mapStateToProps(state = {}) {
2829
refreshConfig: getRefreshConfig(state),
2930
mapInitError: getMapInitError(state),
3031
indexPatternIds: getQueryableUniqueIndexPatternIds(state),
32+
hideToolbarOverlay: isToolbarOverlayHidden(state),
3133
};
3234
}
3335

x-pack/legacy/plugins/maps/public/connected_components/gis_map/view.js

Lines changed: 29 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,11 @@ import uuid from 'uuid/v4';
2121
const RENDER_COMPLETE_EVENT = 'renderComplete';
2222

2323
export class GisMap extends Component {
24-
2524
state = {
2625
isInitialLoadRenderTimeoutComplete: false,
2726
domId: uuid(),
2827
geoFields: [],
29-
}
28+
};
3029

3130
componentDidMount() {
3231
this._isMounted = true;
@@ -65,9 +64,9 @@ export class GisMap extends Component {
6564
if (el) {
6665
el.dispatchEvent(new CustomEvent(RENDER_COMPLETE_EVENT, { bubbles: true }));
6766
}
68-
}
67+
};
6968

70-
_loadGeoFields = async (nextIndexPatternIds) => {
69+
_loadGeoFields = async nextIndexPatternIds => {
7170
if (_.isEqual(nextIndexPatternIds, this._prevIndexPatternIds)) {
7271
// all ready loaded index pattern ids
7372
return;
@@ -78,19 +77,22 @@ export class GisMap extends Component {
7877
const geoFields = [];
7978
try {
8079
const indexPatterns = await getIndexPatternsFromIds(nextIndexPatternIds);
81-
indexPatterns.forEach((indexPattern) => {
80+
indexPatterns.forEach(indexPattern => {
8281
indexPattern.fields.forEach(field => {
83-
if (field.type === ES_GEO_FIELD_TYPE.GEO_POINT || field.type === ES_GEO_FIELD_TYPE.GEO_SHAPE) {
82+
if (
83+
field.type === ES_GEO_FIELD_TYPE.GEO_POINT ||
84+
field.type === ES_GEO_FIELD_TYPE.GEO_SHAPE
85+
) {
8486
geoFields.push({
8587
geoFieldName: field.name,
8688
geoFieldType: field.type,
8789
indexPatternTitle: indexPattern.title,
88-
indexPatternId: indexPattern.id
90+
indexPatternId: indexPattern.id,
8991
});
9092
}
9193
});
9294
});
93-
} catch(e) {
95+
} catch (e) {
9496
// swallow errors.
9597
// the Layer-TOC will indicate which layers are disfunctional on a per-layer basis
9698
}
@@ -100,7 +102,7 @@ export class GisMap extends Component {
100102
}
101103

102104
this.setState({ geoFields });
103-
}
105+
};
104106

105107
_setRefreshTimer = () => {
106108
const { isPaused, interval } = this.props.refreshConfig;
@@ -116,12 +118,9 @@ export class GisMap extends Component {
116118
this._clearRefreshTimer();
117119

118120
if (!isPaused && interval > 0) {
119-
this.refreshTimerId = setInterval(
120-
() => {
121-
this.props.triggerRefreshTimer();
122-
},
123-
interval
124-
);
121+
this.refreshTimerId = setInterval(() => {
122+
this.props.triggerRefreshTimer();
123+
}, interval);
125124
}
126125
};
127126

@@ -134,16 +133,13 @@ export class GisMap extends Component {
134133
// Mapbox does not provide any feedback when rendering is complete.
135134
// Temporary solution is just to wait set period of time after data has loaded.
136135
_startInitialLoadRenderTimer = () => {
137-
setTimeout(
138-
() => {
139-
if (this._isMounted) {
140-
this.setState({ isInitialLoadRenderTimeoutComplete: true });
141-
this._onInitialLoadRenderComplete();
142-
}
143-
},
144-
5000
145-
);
146-
}
136+
setTimeout(() => {
137+
if (this._isMounted) {
138+
this.setState({ isInitialLoadRenderTimeoutComplete: true });
139+
this._onInitialLoadRenderComplete();
140+
}
141+
}, 5000);
142+
};
147143

148144
render() {
149145
const {
@@ -164,14 +160,12 @@ export class GisMap extends Component {
164160
<div data-render-complete data-shared-item>
165161
<EuiCallOut
166162
title={i18n.translate('xpack.maps.map.initializeErrorTitle', {
167-
defaultMessage: 'Unable to initialize map'
163+
defaultMessage: 'Unable to initialize map',
168164
})}
169165
color="danger"
170166
iconType="cross"
171167
>
172-
<p>
173-
{mapInitError}
174-
</p>
168+
<p>{mapInitError}</p>
175169
</EuiCallOut>
176170
</div>
177171
);
@@ -183,21 +177,15 @@ export class GisMap extends Component {
183177
currentPanel = null;
184178
} else if (addLayerVisible) {
185179
currentPanelClassName = 'mapMapLayerPanel-isVisible';
186-
currentPanel = <AddLayerPanel/>;
180+
currentPanel = <AddLayerPanel />;
187181
} else if (layerDetailsVisible) {
188182
currentPanelClassName = 'mapMapLayerPanel-isVisible';
189-
currentPanel = (
190-
<LayerPanel/>
191-
);
183+
currentPanel = <LayerPanel />;
192184
}
193185

194186
let exitFullScreenButton;
195187
if (isFullScreen) {
196-
exitFullScreenButton = (
197-
<ExitFullScreenButton
198-
onExitFullScreenMode={exitFullScreen}
199-
/>
200-
);
188+
exitFullScreenButton = <ExitFullScreenButton onExitFullScreenMode={exitFullScreen} />;
201189
}
202190
return (
203191
<EuiFlexGroup
@@ -213,10 +201,9 @@ export class GisMap extends Component {
213201
geoFields={this.state.geoFields}
214202
renderTooltipContent={renderTooltipContent}
215203
/>
216-
<ToolbarOverlay
217-
addFilters={addFilters}
218-
geoFields={this.state.geoFields}
219-
/>
204+
{!this.props.hideToolbarOverlay && (
205+
<ToolbarOverlay addFilters={addFilters} geoFields={this.state.geoFields} />
206+
)}
220207
<WidgetOverlay/>
221208
</EuiFlexItem>
222209

x-pack/legacy/plugins/maps/public/connected_components/map/mb/index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ import {
2020
getLayerList,
2121
getMapReady,
2222
getGoto,
23-
getScrollZoom
23+
getScrollZoom,
24+
isInteractiveDisabled,
25+
isTooltipControlDisabled,
2426
} from '../../../selectors/map_selectors';
2527
import { getInspectorAdapters } from '../../../reducers/non_serializable_instances';
2628

@@ -31,7 +33,9 @@ function mapStateToProps(state = {}) {
3133
goto: getGoto(state),
3234
inspectorAdapters: getInspectorAdapters(state),
3335
tooltipState: getTooltipState(state),
34-
scrollZoom: getScrollZoom(state)
36+
scrollZoom: getScrollZoom(state),
37+
disableInteractive: isInteractiveDisabled(state),
38+
disableTooltipControl: isTooltipControlDisabled(state)
3539
};
3640
}
3741

0 commit comments

Comments
 (0)