Skip to content

Commit 5ee2da9

Browse files
committed
load map settings in embeddable
1 parent f8549bf commit 5ee2da9

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

x-pack/plugins/maps/public/embeddable/map_embeddable.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {
2828
} from '../../../../../src/plugins/data/public';
2929
import { GisMap } from '../connected_components/gis_map';
3030
import { createMapStore, MapStore } from '../reducers/store';
31+
import { MapSettings } from '../reducers/map';
3132
import {
3233
setGotoWithCenter,
3334
replaceLayerList,
@@ -40,6 +41,7 @@ import {
4041
hideLayerControl,
4142
hideViewControl,
4243
setHiddenLayers,
44+
setMapSettings,
4345
} from '../actions/map_actions';
4446
import { MapCenterAndZoom } from '../../common/descriptor_types';
4547
import { setReadOnly, setIsLayerTOCOpen, setOpenTOCDetails } from '../actions/ui_actions';
@@ -60,6 +62,7 @@ interface MapEmbeddableConfig {
6062
editable: boolean;
6163
title?: string;
6264
layerList: unknown[];
65+
settings?: MapSettings;
6366
}
6467

6568
export interface MapEmbeddableInput extends EmbeddableInput {
@@ -97,6 +100,7 @@ export class MapEmbeddable extends Embeddable<MapEmbeddableInput, MapEmbeddableO
97100
private _prevFilters?: Filter[];
98101
private _domNode?: HTMLElement;
99102
private _unsubscribeFromStore?: Unsubscribe;
103+
private _settings?: MapSettings;
100104

101105
constructor(
102106
config: MapEmbeddableConfig,
@@ -119,6 +123,7 @@ export class MapEmbeddable extends Embeddable<MapEmbeddableInput, MapEmbeddableO
119123
this._renderTooltipContent = renderTooltipContent;
120124
this._eventHandlers = eventHandlers;
121125
this._layerList = config.layerList;
126+
this._settings = config.settings;
122127
this._store = createMapStore();
123128

124129
this._subscription = this.getInput$().subscribe(input => this.onContainerStateChanged(input));
@@ -194,6 +199,10 @@ export class MapEmbeddable extends Embeddable<MapEmbeddableInput, MapEmbeddableO
194199
this._store.dispatch(setReadOnly(true));
195200
this._store.dispatch(disableScrollZoom());
196201

202+
if (this._settings) {
203+
this._store.dispatch(setMapSettings(this._settings));
204+
}
205+
197206
if (_.has(this.input, 'isLayerTOCOpen')) {
198207
this._store.dispatch(setIsLayerTOCOpen(this.input.isLayerTOCOpen));
199208
}

x-pack/plugins/maps/public/embeddable/map_embeddable_factory.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,22 @@ export class MapEmbeddableFactory implements EmbeddableFactoryDefinition {
9393
const layerList = getInitialLayers(savedMap.layerListJSON);
9494
const indexPatterns = await this._getIndexPatterns(layerList);
9595

96+
let settings;
97+
if (savedMap.mapStateJSON) {
98+
const mapState = JSON.parse(savedMap.mapStateJSON);
99+
if (mapState.settings) {
100+
settings = mapState.settings;
101+
}
102+
}
103+
96104
const embeddable = new MapEmbeddable(
97105
{
98106
layerList,
99107
title: savedMap.title,
100108
editUrl: getHttp().basePath.prepend(createMapPath(savedObjectId)),
101109
indexPatterns,
102110
editable: await this.isEditable(),
111+
settings,
103112
},
104113
input,
105114
parent

0 commit comments

Comments
 (0)