diff --git a/src/essence/Basics/Formulae_/Formulae_.js b/src/essence/Basics/Formulae_/Formulae_.js index 82e683e1..259d223d 100644 --- a/src/essence/Basics/Formulae_/Formulae_.js +++ b/src/essence/Basics/Formulae_/Formulae_.js @@ -1522,6 +1522,27 @@ var Formulae_ = { }) return g }, + parseIntoGeoJSON(data) { + let d + // [] + if (Array.isArray(data) && data.length === 0) { + d = { type: 'FeatureCollection', features: [] } + } + // [] + else if ( + Array.isArray(data) && + data[0] && + data[0].type === 'FeatureCollection' + ) { + const nextData = { type: 'FeatureCollection', features: [] } + data.forEach((fc) => { + if (fc.type === 'FeatureCollection') + nextData.features = nextData.features.concat(fc.features) + }) + d = nextData + } + return d == null ? data : d + }, // Gets all tiles with tile xyz at zoom z tilesWithin(xyz, z) { let tiles = [] diff --git a/src/essence/Basics/Layers_/LayerCapturer.js b/src/essence/Basics/Layers_/LayerCapturer.js index 6fcbb4e0..03fd2a37 100644 --- a/src/essence/Basics/Layers_/LayerCapturer.js +++ b/src/essence/Basics/Layers_/LayerCapturer.js @@ -188,7 +188,10 @@ export const captureVector = (layerObj, options, cb, dynamicCb) => { L_.clearVectorLayer(layerObj.name) } }) - cb({ type: 'FeatureCollection', features: [] }, true) + cb( + { type: 'FeatureCollection', check: true, features: [] }, + true + ) break case 'api': break @@ -277,6 +280,8 @@ export const captureVector = (layerObj, options, cb, dynamicCb) => { delete data.Features } + data = F_.parseIntoGeoJSON(data) + const lastLoc = _layerRequestLastLoc[layerObj.name] const nowLoc = L_.Map_.map.getCenter() diff --git a/src/essence/Basics/Layers_/Layers_.js b/src/essence/Basics/Layers_/Layers_.js index 6f6d6029..82214e3a 100644 --- a/src/essence/Basics/Layers_/Layers_.js +++ b/src/essence/Basics/Layers_/Layers_.js @@ -2738,6 +2738,12 @@ const L_ = { syncSublayerData: async function (layerName, onlyClear) { layerName = L_.asLayerUUID(layerName) + if ( + L_.layers.layer[layerName] == null || + L_.layers.layer[layerName] == false + ) + return + try { let geojson = L_.layers.layer[layerName].toGeoJSON( L_.GEOJSON_PRECISION diff --git a/src/essence/Basics/Map_/Map_.js b/src/essence/Basics/Map_/Map_.js index 137fd1c1..baddd1e3 100644 --- a/src/essence/Basics/Map_/Map_.js +++ b/src/essence/Basics/Map_/Map_.js @@ -814,25 +814,7 @@ async function makeVectorLayer( ) function add(data, allowInvalid) { - // [] - if (Array.isArray(data) && data.length === 0) { - data = { type: 'FeatureCollection', features: [] } - } - // [] - else if ( - Array.isArray(data) && - data[0] && - data[0].type === 'FeatureCollection' - ) { - const nextData = { type: 'FeatureCollection', features: [] } - data.forEach((fc) => { - if (fc.type === 'FeatureCollection') - nextData.features = nextData.features.concat( - fc.features - ) - }) - data = nextData - } + data = F_.parseIntoGeoJSON(data) let invalidGeoJSONTrace = gjv.valid(data, true) const allowableErrors = [`position must only contain numbers`]