Skip to content

Commit

Permalink
fix(geojson): clean up of props 📍
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 f0e131e commit 2cc57b1
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions src/layers/mapbox/VLayerMapboxGeojson.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
</div>
</template>
<script lang="ts">
import type { FeatureCollection } from 'geojson';
import type { AnyLayer, GeoJSONSourceRaw } from 'mapbox-gl';
import type { PropType, Ref } from 'vue';
import { defineComponent, onMounted, ref, watch } from 'vue';
Expand All @@ -24,7 +23,7 @@
required: true,
},
source: {
type: Object as PropType<FeatureCollection | GeoJSONSourceRaw>,
type: Object as PropType<GeoJSONSourceRaw>,
required: true,
},
layer: {
Expand All @@ -48,15 +47,6 @@
source: props.sourceId,
};
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', () => {
// https://github.com/mapbox/mapbox-gl-js/issues/2268#issuecomment-401979967
const styleTimeout = () => {
Expand Down Expand Up @@ -89,7 +79,7 @@
* @returns {void}
*/
function addLayer(): void {
map.value.addSource(props.sourceId, source());
map.value.addSource(props.sourceId, props.source);
map.value.addLayer(layer, props.before);
}
},
Expand Down

0 comments on commit 2cc57b1

Please sign in to comment.