From 0ded1f5b7f22aef426dcce1e45a513209fda4ca7 Mon Sep 17 00:00:00 2001 From: Vinayak Kulkarni <19776877+vinayakkulkarni@users.noreply.github.com> Date: Thu, 7 Jul 2022 15:38:17 +0530 Subject: [PATCH] =?UTF-8?q?feat(geojson-layer):=20pass=20source=20as=20`Ge?= =?UTF-8?q?oJSONSourceRaw`=20=F0=9F=95=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Vinayak Kulkarni <19776877+vinayakkulkarni@users.noreply.github.com> --- src/layers/mapbox/VLayerMapboxGeojson.vue | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/layers/mapbox/VLayerMapboxGeojson.vue b/src/layers/mapbox/VLayerMapboxGeojson.vue index 9fa29c2f..6d2b1cd3 100644 --- a/src/layers/mapbox/VLayerMapboxGeojson.vue +++ b/src/layers/mapbox/VLayerMapboxGeojson.vue @@ -24,7 +24,7 @@ required: true, }, source: { - type: Object as PropType, + type: Object as PropType, required: true, }, layer: { @@ -47,9 +47,14 @@ id: props.layerId, source: props.sourceId, }; - const source: GeoJSONSourceRaw = { - type: 'geojson', - data: props.source, + + const source = () => { + // Assuming the source is FeatureCollection + if ('type' in props.source) { + return { type: 'geojson', data: props.source } as GeoJSONSourceRaw; + } else { + return props.source; + } }; map.value.on('style.load', () => { @@ -84,7 +89,7 @@ * @returns {void} */ function addLayer(): void { - map.value.addSource(props.sourceId, source); + map.value.addSource(props.sourceId, source()); map.value.addLayer(layer, props.before); } },