Skip to content

Commit cea0b0c

Browse files
committed
refactor: update boundary type to be equal to the implementation in #374
1 parent 73b610e commit cea0b0c

File tree

2 files changed

+23
-12
lines changed

2 files changed

+23
-12
lines changed

src/core/types/plugin.ts

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,30 +24,36 @@ export interface PluginOptions {
2424
layoutTag?: keyof typeof NineLayoutTag
2525
}
2626

27-
export type BoundaryOnError = 'strict' | 'permissive'
28-
29-
export interface LayerBoundPluginOptions extends PluginOptions {
27+
interface BoundaryOptions {
3028
/**
31-
* Set to check whether something is within the layer's boundaries.
29+
* ID of the vector layer to restrict requests to.
3230
* The layer must contain vectors. This is useful for restricted maps to avoid
3331
* selecting unfit coordinates.
3432
*/
35-
boundaryLayerId?: string
33+
layerId: string
34+
35+
/**
36+
* If the boundary layer check does not work due to loading or configuration
37+
* errors, style `'strict'` will disable the affected feature, and style
38+
* `'permissive'` will act as if no {@link layerId} was set.
39+
*
40+
* @defaultValue 'permissive'
41+
*/
42+
onError?: 'strict' | 'permissive'
3643

3744
/**
3845
* If the boundary layer check does not work due to loading or configuration
3946
* errors, style `'strict'` will disable the affected feature, and style
4047
* `'permissive'` will act as if no boundaryLayerId was set.
4148
* @defaultValue `'permissive'`
4249
*/
50+
}
4351

44-
boundaryOnError?: BoundaryOnError
45-
52+
export interface LayerBoundPluginOptions extends PluginOptions {
4653
/**
47-
* Whether the user should, in error cases, be informed with a toast.
48-
* @defaultValue `false`
54+
* Set to check whether something is within the layer's boundaries.
4955
*/
50-
toast?: boolean
56+
boundary?: BoundaryOptions
5157
}
5258

5359
export type PolarPluginStore<

src/plugins/geoLocation/store.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ export const useGeoLocationStore = defineStore('plugins/geoLocation', () => {
157157

158158
const boundaryCheckPassed = await passesBoundaryCheck(
159159
coreStore.map,
160-
configuration.value.boundaryLayerId,
160+
configuration.value.boundary.layerId,
161161
coordinatesInMapCrs
162162
)
163163

@@ -166,7 +166,7 @@ export const useGeoLocationStore = defineStore('plugins/geoLocation', () => {
166166

167167
const showBoundaryLayerError =
168168
typeof boundaryCheckPassed === 'symbol' &&
169-
configuration.value.boundaryOnError === 'strict'
169+
configuration.value.boundary.onError === 'strict'
170170

171171
if (!isCoordinateInExtent || showBoundaryLayerError) {
172172
printPositioningFailed(showBoundaryLayerError)
@@ -314,26 +314,31 @@ export const useGeoLocationStore = defineStore('plugins/geoLocation', () => {
314314
return {
315315
/** @internal */
316316
setupPlugin,
317+
317318
/** @internal */
318319
teardownPlugin,
320+
319321
/**
320322
* The plugin's current state. It can either currently have the user's
321323
* position ('LOCATED'), be ready to retrieve it ('LOCATABLE'), or be
322324
* disabled ('DISABLED') due to the user or browser settings not allowing
323325
* the Geolocation API access.
324326
*/
325327
state,
328+
326329
/**
327330
* The action that would currently unfold upon clicking the icon, depending
328331
* on the state. If the state is 'DISABLED', nothing is done. In the other
329332
* states, the geolocation procedure is (re-)run.
330333
*/
331334
action,
335+
332336
/**
333337
* While in state 'LOCATED', the user's location's coordinated are available
334338
* as [number, number] of the map's configured CRS.
335339
*/
336340
position,
341+
337342
/**
338343
* Initially null. If no boundary check is configured or the check is
339344
* passed, this field holds `true`. If the boundary check is not passed,

0 commit comments

Comments
 (0)