Feat(initial view) - #909
Conversation
Co-authored-by: joselin.guevarahoppe@dataport.de
|
I changed the base branch to |
|
Please add another commit here to trigger the creation of the PR preview @LivMoeser |
| /** | ||
| * Defines if the geoLocation button is rendered independent or as part of the | ||
| * icon menu. | ||
| * @defaultValue `'independent'` | ||
| */ | ||
|
|
There was a problem hiding this comment.
| /** | |
| * Defines if the geoLocation button is rendered independent or as part of the | |
| * icon menu. | |
| * @defaultValue `'independent'` | |
| */ |
| export interface InitialViewPluginOptions extends PluginOptions { | ||
| renderType?: 'independent' | 'iconMenu' | ||
| startCenter?: [number, number] | ||
| startResolution?: number | ||
| } |
There was a problem hiding this comment.
- InitialView: Add plugin with a button to return to the initial map view #893 describes that the plugin should not receive any additional configuration options beside
renderType. - A similar TSDoc comment for
renderTypelike inGeoLocationPluginOptionsshould be added here. startCenteris a required configuration option. Thus, it can always be retrieved fromcoreStore.configuration.startCenterstartResolutionis an optional configuration option but it has a default value. Thusm it can always safely be retrieved fromcoreStore.configuration.startResolution
| import type { PluginId as ReturnToInitialViewPluginId } from '@/plugins/initialView' | ||
| import type { resourcesEn as ReturnToInitialViewResources } from '@/plugins/initialView/locales' | ||
| import type { useInitialViewStore as ReturnToInitialViewStore } from '@/plugins/initialView/store' |
There was a problem hiding this comment.
The names should reflect the name of the plugin. Thus, dropping the ReturnTo is the way forward.
| import { useInitialViewStore } from '../store' | ||
| import { PluginId } from '../types' | ||
|
|
||
| const InitialViewStore = useInitialViewStore() |
There was a problem hiding this comment.
Classes, components and types / interfaces are commonly using PascalCase while other variables are using camelCase.
| :hint="$t(($) => $.label.return, { ns: PluginId })" | ||
| icon="kern-icon--home" | ||
| tooltip-position="left" | ||
| @click="onClick" |
There was a problem hiding this comment.
| @click="onClick" | |
| @click="initialViewStore.returnToInitialView" |
As the local function onClick only calls returnToInitialView, this remove bloat.
| enabledPlugins.includes('returnToInitialView') && | ||
| ReturnToInitialView({ | ||
| displayComponent: true, | ||
| layoutTag: 'TOP_RIGHT', | ||
| renderType: 'iconMenu', | ||
| }), |
There was a problem hiding this comment.
If the plugin is supposed to be added to the iconMenu it should be done in L32-46. In that case, that information should be added to the TSDoc comment of createMap in line 101.
| import Fullscreen from '@/plugins/fullscreen' | ||
| import GeoLocation from '@/plugins/geoLocation' | ||
| import IconMenu from '@/plugins/iconMenu' | ||
| import ReturnToInitialView from '@/plugins/initialView' |
There was a problem hiding this comment.
Naming the import InitialView seems more fitting.
| return { | ||
| startCenter, | ||
| startResolution, | ||
| returnToInitialView, |
There was a problem hiding this comment.
| returnToInitialView, | |
| /** @alpha */ | |
| returnToInitialView, |
| iconMenu?: IconMenuPluginOptions | ||
|
|
||
| /** Configuration for iInitialView plugin. */ | ||
| returnToInitialView?: InitialViewPluginOptions |
There was a problem hiding this comment.
| returnToInitialView?: InitialViewPluginOptions | |
| initialView?: InitialViewPluginOptions |
| /** Configuration for iconMenu plugin. */ | ||
| iconMenu?: IconMenuPluginOptions | ||
|
|
||
| /** Configuration for iInitialView plugin. */ |
There was a problem hiding this comment.
| /** Configuration for iInitialView plugin. */ | |
| /** Configuration for initialView plugin. */ |
Co-authored-by: LivMoeser <liv.moeser@dataport.de>
Co-authored-by: LivMoeser <liv.moeser@dataport.de>
Co-authored-by: LivMoeser <liv.moeser@dataport.de>
|
| <PolarIconButton | ||
| :hint="$t(($) => $.label.return, { ns: PluginId })" | ||
| icon="kern-icon--home" | ||
| tooltip-position="left" |
There was a problem hiding this comment.
The tooltipPosition should be based on where it is rendered.
Zoom added the following getter to its store to solve this issue which can be added the same way in the store of this plugin:
const tooltipPosition = computed(() =>
renderType.value === 'independent'
? layoutTag.value.includes('RIGHT')
? 'left'
: 'right'
: coreStore.getPluginStore('iconMenu')?.layoutTag.includes('RIGHT')
? 'left'
: 'right'
) as ComputedRef<'left' | 'right'>
Summary
New One-Button Plugin that returns the map to its initial placing and zoom.
Instructions for local reproduction and review
Relevant tickets, issues, et cetera
#893