Added support for raw GeoJSON

This commit is contained in:
orangemug
2019-10-19 13:11:29 +01:00
parent 201ecac156
commit 19e82e5890
2 changed files with 41 additions and 6 deletions

View File

@@ -52,7 +52,14 @@ function editorMode(source) {
if(source.tiles) return 'tilexyz_vector'
return 'tilejson_vector'
}
if(source.type === 'geojson') return 'geojson'
if(source.type === 'geojson') {
if (typeof(source.data) === "string") {
return 'geojson_url';
}
else {
return 'geojson_json';
}
}
return null
}
@@ -106,10 +113,14 @@ class AddSource extends React.Component {
defaultSource(mode) {
const source = (this.state || {}).source || {}
switch(mode) {
case 'geojson': return {
case 'geojson_url': return {
type: 'geojson',
data: source.data || 'http://localhost:3000/geojson.json'
}
case 'geojson_json': return {
type: 'geojson',
data: source.data || {}
}
case 'tilejson_vector': return {
type: 'vector',
url: source.url || 'http://localhost:3000/tilejson.json'
@@ -155,7 +166,8 @@ class AddSource extends React.Component {
<InputBlock label={"Source Type"} doc={latest.source_vector.type.doc}>
<SelectInput
options={[
['geojson', 'GeoJSON'],
['geojson_json', 'GeoJSON (JSON)'],
['geojson_url', 'GeoJSON (URL)'],
['tilejson_vector', 'Vector (TileJSON URL)'],
['tilexyz_vector', 'Vector (XYZ URLs)'],
['tilejson_raster', 'Raster (TileJSON URL)'],