Skip to content

Commit

Permalink
feat(geojson-layer): pass source as GeoJSONSourceRaw 馃暫
Browse files Browse the repository at this point in the history
Signed-off-by: Vinayak Kulkarni <19776877+vinayakkulkarni@users.noreply.github.com>
  • Loading branch information
vinayakkulkarni committed Jul 7, 2022
1 parent b40674c commit 0ded1f5
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/layers/mapbox/VLayerMapboxGeojson.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
required: true,
},
source: {
type: Object as PropType<FeatureCollection>,
type: Object as PropType<FeatureCollection | GeoJSONSourceRaw>,
required: true,
},
layer: {
Expand All @@ -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', () => {
Expand Down Expand Up @@ -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);
}
},
Expand Down

0 comments on commit 0ded1f5

Please sign in to comment.