diff --git a/src/components/modals/SourcesModal.jsx b/src/components/modals/SourcesModal.jsx index e291607f..7d131707 100644 --- a/src/components/modals/SourcesModal.jsx +++ b/src/components/modals/SourcesModal.jsx @@ -60,6 +60,12 @@ function editorMode(source) { return 'geojson_json'; } } + if(source.type === 'image') { + return 'image'; + } + if(source.type === 'video') { + return 'video'; + } return null } @@ -153,6 +159,28 @@ class AddSource extends React.Component { minzoom: source.minzoom || 0, maxzoom: source.maxzoom || 14 } + case 'image': return { + type: 'image', + url: `${protocol}//localhost:3000/image.png`, + coordinates: [ + [0,0], + [0,0], + [0,0], + [0,0], + ], + } + case 'video': return { + type: 'video', + urls: [ + `${protocol}//localhost:3000/movie.mp4` + ], + coordinates: [ + [0,0], + [0,0], + [0,0], + [0,0], + ], + } default: return {} } } @@ -185,6 +213,8 @@ class AddSource extends React.Component { ['tilexyz_raster', 'Raster (XYZ URL)'], ['tilejson_raster-dem', 'Raster DEM (TileJSON URL)'], ['tilexyz_raster-dem', 'Raster DEM (XYZ URLs)'], + ['image', 'Image'], + ['video', 'Video'], ]} onChange={mode => this.setState({mode: mode, source: this.defaultSource(mode)})} value={this.state.mode} diff --git a/src/components/sources/SourceTypeEditor.jsx b/src/components/sources/SourceTypeEditor.jsx index 8ed46728..1726b860 100644 --- a/src/components/sources/SourceTypeEditor.jsx +++ b/src/components/sources/SourceTypeEditor.jsx @@ -6,6 +6,8 @@ import StringInput from '../inputs/StringInput' import UrlInput from '../inputs/UrlInput' import NumberInput from '../inputs/NumberInput' import SelectInput from '../inputs/SelectInput' +import DynamicArrayInput from '../inputs/DynamicArrayInput' +import ArrayInput from '../inputs/ArrayInput' import JSONEditor from '../layers/JSONEditor' @@ -88,6 +90,100 @@ class TileURLSourceEditor extends React.Component { } } +class ImageSourceEditor extends React.Component { + static propTypes = { + source: PropTypes.object.isRequired, + onChange: PropTypes.func.isRequired, + } + + render() { + const changeCoord = (idx, val) => { + const coordinates = this.props.source.coordinates.slice(0); + coordinates[idx] = val; + + this.props.onChange({ + ...this.props.source, + coordinates, + }); + } + + return