Skip to content

Commit

Permalink
Add a MapboxFullscreenControl component
Browse files Browse the repository at this point in the history
  • Loading branch information
titouanmathis committed Jul 8, 2024
1 parent 2d4e380 commit 1204ba1
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 1 deletion.
2 changes: 2 additions & 0 deletions packages/demo/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
MapboxNavigationControl,
MapboxPopup,
MapboxCluster,
MapboxFullscreenControl,
} from '@studiometa/vue-mapbox-gl';
import 'mapbox-gl/dist/mapbox-gl.css';
import '@mapbox/mapbox-gl-geocoder/lib/mapbox-gl-geocoder.css';
Expand Down Expand Up @@ -84,6 +85,7 @@
:zoom="zoom"
@mb-created="createdHandler"
@mb-click="eventHandler">
<MapboxFullscreenControl position="bottom-left" />
<MapboxImages :sources="iconSources">
<MapboxLayer id="pois" :options="layerOptions" />
</MapboxImages>
Expand Down
38 changes: 38 additions & 0 deletions packages/vue-mapbox-gl/components/MapboxFullscreenControl.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<template>
<div />
</template>

<script>
import mapboxgl from 'mapbox-gl';
if (!mapboxgl) {
throw new Error('mapboxgl is not installed.');
}
/**
* Component's props definition, we need to declare it outside the component
* to be able to test the default values and the types.
* @see https://docs.mapbox.com/mapbox-gl-js/api/markers/#fullscreencontrol
* @type {object}
*/
const propsConfig = {
// eslint-disable-next-line vue/require-default-prop
container: typeof HTMLElement !== 'undefined' ? HTMLElement : Object,
position: {
type: String,
default: 'top-right',
},
};
</script>

<script setup>
import { useControl } from '../composables/index.js';
const props = defineProps(propsConfig);
const { control, map } = useControl(mapboxgl.FullscreenControl, {
propsConfig,
props,
});
defineExpose({ control });
</script>
2 changes: 1 addition & 1 deletion packages/vue-mapbox-gl/components/MapboxGeocoder.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
}
/**
*Component's props definition, we need to declare it outside the component
* Component's props definition, we need to declare it outside the component
* to be able to test the default values and the types.
* @see https://github.com/mapbox/mapbox-gl-geocoder/blob/master/API.md#parameters
* @type {object}
Expand Down
1 change: 1 addition & 0 deletions packages/vue-mapbox-gl/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ export { default as MapboxMarker } from './MapboxMarker.vue';
export { default as MapboxNavigationControl } from './MapboxNavigationControl.vue';
export { default as MapboxPopup } from './MapboxPopup.vue';
export { default as MapboxSource } from './MapboxSource.vue';
export { default as MapboxFullscreenControl } from './MapboxFullscreenControl.vue';

0 comments on commit 1204ba1

Please sign in to comment.