Skip to content

Commit 04b16d3

Browse files
authored
fix(exported map): show effects button in exported map (html) (#3369)
* fix(exported map): show effects button in exported map Signed-off-by: Ihor Dykhta <dikhta.igor@gmail.com> * fix top margin Signed-off-by: Ihor Dykhta <dikhta.igor@gmail.com> --------- Signed-off-by: Ihor Dykhta <dikhta.igor@gmail.com>
1 parent 31243cb commit 04b16d3

1 file changed

Lines changed: 61 additions & 1 deletion

File tree

src/utils/src/export-map-html.ts

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,66 @@ export const exportMapToHTML = (options, version = KEPLER_GL_VERSION) => {
144144
/** END STORE **/
145145
146146
/** COMPONENTS **/
147+
/** Custom map control factory to add Effects button + panel **/
148+
var CustomMapControlFactory = (function createCustomMapControl(react, keplerGl) {
149+
var EffectControlFactory = keplerGl.EffectControlFactory;
150+
var EffectManagerFactory = keplerGl.EffectManagerFactory;
151+
var MapControlFactory = keplerGl.MapControlFactory;
152+
153+
if (!EffectControlFactory || !EffectManagerFactory || !MapControlFactory) {
154+
console.warn('kepler.gl: Effect factories not available, skipping effect control injection');
155+
return null;
156+
}
157+
158+
function EffectMapControlFactory(EffectControl, EffectManager) {
159+
var args = Array.prototype.slice.call(arguments, 2);
160+
var MapControl = MapControlFactory.apply(null, args);
161+
var actionComponents = (MapControl.defaultActionComponents || []).concat([EffectControl]);
162+
163+
var EffectMapControl = function EffectMapControl(props) {
164+
var showEffects = Boolean(props.mapControls && props.mapControls.effect && props.mapControls.effect.active);
165+
return react.createElement(
166+
'div',
167+
{style: {
168+
position: 'absolute',
169+
display: 'flex',
170+
top: (props.top || 0) + 'px',
171+
right: 0,
172+
zIndex: 1,
173+
maxHeight: '100%',
174+
pointerEvents: 'none'
175+
}},
176+
react.createElement(
177+
'div',
178+
{style: {position: 'relative', pointerEvents: 'all'}},
179+
react.createElement(MapControl, Object.assign({}, props, {top: 0, actionComponents: actionComponents}))
180+
),
181+
showEffects
182+
? react.createElement('div', {
183+
style: {
184+
maxHeight: '100%',
185+
overflow: 'hidden',
186+
display: 'flex',
187+
flexDirection: 'column',
188+
pointerEvents: 'all',
189+
marginTop: '10px'
190+
}
191+
}, react.createElement(EffectManager, null))
192+
: null
193+
);
194+
};
195+
196+
return EffectMapControl;
197+
}
198+
EffectMapControlFactory.deps = [EffectControlFactory, EffectManagerFactory].concat(MapControlFactory.deps);
199+
200+
return [MapControlFactory, EffectMapControlFactory];
201+
}(React, KeplerGl));
202+
203+
var KeplerGlComponent = CustomMapControlFactory
204+
? KeplerGl.injectComponents([CustomMapControlFactory])
205+
: KeplerGl.KeplerGl;
206+
147207
var KeplerElement = (function makeKeplerElement(react, keplerGl, mapboxToken) {
148208
var LogoSvg = function LogoSvg() {
149209
return react.createElement(
@@ -199,7 +259,7 @@ export const exportMapToHTML = (options, version = KEPLER_GL_VERSION) => {
199259
'div',
200260
{style: {position: 'absolute', left: 0, width: '100vw', height: '100vh'}},
201261
${options.mode === EXPORT_HTML_MAP_MODES.READ ? 'LogoSvg(),' : ''}
202-
react.createElement(keplerGl.KeplerGl, {
262+
react.createElement(KeplerGlComponent, {
203263
mapboxApiAccessToken: mapboxToken,
204264
id: "map",
205265
width: windowDimension.width,

0 commit comments

Comments
 (0)