Skip to content

Commit 62ff507

Browse files
wip
1 parent 045082e commit 62ff507

File tree

5 files changed

+53
-14
lines changed

5 files changed

+53
-14
lines changed

src/EditorControls.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,10 @@ class EditorControls extends Component {
344344
move(graphDiv.layout.annotations);
345345
}
346346

347+
if (payload.path === 'layout.mapbox.layers') {
348+
move(graphDiv.layout[payload.mapboxId].layers);
349+
}
350+
347351
const updatedData = payload.path.startsWith('data')
348352
? graphDiv.data.slice()
349353
: graphDiv.data;

src/components/containers/MapboxLayersAccordion.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,19 @@ class MapboxLayersAccordion extends Component {
4040
updateContainer({
4141
[`layers[${mapboxLayerIndex}]`]: {
4242
name: `Layer ${mapboxLayerIndex}`,
43-
sourcetype: 'geojson',
44-
source: {
45-
type: 'FeatureCollection',
46-
features: [],
47-
},
43+
sourcetype: 'raster',
44+
below: '',
4845
},
4946
});
5047
}
5148
},
5249
};
5350

54-
return <PlotlyPanel addAction={addAction}>{content ? content : null}</PlotlyPanel>;
51+
return (
52+
<PlotlyPanel addAction={addAction} canReorder>
53+
{content ? content : null}
54+
</PlotlyPanel>
55+
);
5556
}
5657
}
5758

src/components/fields/derived.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {UnconnectedTextEditor} from './TextEditor';
1313
import {UnconnectedVisibilitySelect} from './VisibilitySelect';
1414
import {connectToContainer, getAllAxes, getAxisTitle, axisIdToAxisName} from 'lib';
1515
import PropTypes from 'prop-types';
16+
import Text from './Text';
1617

1718
export const AxisAnchorDropdown = connectToContainer(UnconnectedDropdown, {
1819
modifyPlotProps: (props, context, plotProps) => {
@@ -662,6 +663,23 @@ export const FillDropdown = connectToContainer(UnconnectedDropdown, {
662663
},
663664
});
664665

666+
export const MapboxSourceArray = connectToContainer(Text, {
667+
modifyPlotProps: (props, context, plotProps) => {
668+
const {fullValue, updatePlot} = plotProps;
669+
if (plotProps.fullValue && plotProps.fullValue.length > 0) {
670+
plotProps.fullValue = fullValue[0];
671+
}
672+
673+
plotProps.updatePlot = v => {
674+
if (v.length) {
675+
updatePlot([v]);
676+
} else {
677+
updatePlot([]);
678+
}
679+
};
680+
},
681+
});
682+
665683
export const MapboxStyleDropdown = connectToContainer(UnconnectedDropdown, {
666684
modifyPlotProps: (props, context, plotProps) => {
667685
const {mapBoxAccess, localize: _} = context;

src/default_panels/StyleMapsPanel.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,21 @@ import {
99
Radio,
1010
Numeric,
1111
ColorPicker,
12+
MapboxSourceArray,
1213
} from '../components';
1314

1415
const StyleMapsPanel = (props, {localize: _}) => (
1516
<SubplotAccordion>
1617
<PlotlySection name={_('Base Map')} attr="style">
17-
<MapboxStyleDropdown label={_('Tiles')} attr="style" />
18+
<MapboxStyleDropdown label={_('Tile Source')} attr="style" />
1819
</PlotlySection>
1920
<PlotlySection name={_('Layers')} attr="style">
2021
<MapboxLayersAccordion>
2122
<Radio
22-
attr="visible"
23-
options={[{label: _('Show'), value: true}, {label: _('Hide'), value: false}]}
24-
/>
25-
<Radio
26-
label={_('Layer Type')}
27-
attr="sourcetype"
28-
options={[{label: _('GeoJSON'), value: 'geojson'}, {label: _('Tiles'), value: 'raster'}]}
23+
attr="below"
24+
options={[{label: _('Above Data'), value: ''}, {label: _('Below Data'), value: 'traces'}]}
2925
/>
26+
<MapboxSourceArray label={_('Tile Source URL')} attr="source" show />
3027
</MapboxLayersAccordion>
3128
</PlotlySection>
3229
<PlotlySection name={_('Map Positioning')}>

src/lib/connectLayersToMapbox.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export default function connectLayersToMapbox(WrappedComponent) {
1010

1111
this.deleteMapboxLayer = this.deleteMapboxLayer.bind(this);
1212
this.updateMapboxLayer = this.updateMapboxLayer.bind(this);
13+
this.moveMapboxLayer = this.moveMapboxLayer.bind(this);
1314
this.setLocals(props, context);
1415
}
1516

@@ -33,6 +34,7 @@ export default function connectLayersToMapbox(WrappedComponent) {
3334
!this.context.getValObject ? null : this.context.getValObject(`layers[].${attr}`),
3435
updateContainer: this.updateMapboxLayer,
3536
deleteContainer: this.deleteMapboxLayer,
37+
moveContainer: this.moveMapboxLayer,
3638
container: this.container,
3739
fullContainer: this.fullContainer,
3840
};
@@ -60,6 +62,22 @@ export default function connectLayersToMapbox(WrappedComponent) {
6062
}
6163
}
6264

65+
moveMapboxLayer(direction) {
66+
if (this.context.onUpdate) {
67+
const mapboxLayerIndex = this.props.mapboxLayerIndex;
68+
const desiredIndex = direction === 'up' ? mapboxLayerIndex - 1 : mapboxLayerIndex + 1;
69+
this.context.onUpdate({
70+
type: EDITOR_ACTIONS.MOVE_TO,
71+
payload: {
72+
fromIndex: mapboxLayerIndex,
73+
toIndex: desiredIndex,
74+
mapboxId: this.context.fullContainer._subplot.id,
75+
path: 'layout.mapbox.layers',
76+
},
77+
});
78+
}
79+
}
80+
6381
render() {
6482
return <WrappedComponent {...this.props} />;
6583
}
@@ -85,6 +103,7 @@ export default function connectLayersToMapbox(WrappedComponent) {
85103
MapboxLayerConnectedComponent.childContextTypes = {
86104
updateContainer: PropTypes.func,
87105
deleteContainer: PropTypes.func,
106+
moveContainer: PropTypes.func,
88107
container: PropTypes.object,
89108
fullContainer: PropTypes.object,
90109
getValObject: PropTypes.func,

0 commit comments

Comments
 (0)