Skip to content

Feat(initial view) - #909

Open
LivMoeser wants to merge 9 commits into
nextfrom
feat(initialView)
Open

Feat(initial view)#909
LivMoeser wants to merge 9 commits into
nextfrom
feat(initialView)

Conversation

@LivMoeser

@LivMoeser LivMoeser commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

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

@LivMoeser
LivMoeser requested a review from a team July 30, 2026 11:19
@oeninghe-dataport
oeninghe-dataport changed the base branch from main to next July 30, 2026 11:36
@oeninghe-dataport

Copy link
Copy Markdown
Collaborator

I changed the base branch to next as this PR is about POLAR@3.

@oeninghe-dataport

Copy link
Copy Markdown
Collaborator

Please add another commit here to trigger the creation of the PR preview @LivMoeser

@dopenguin dopenguin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread src/plugins/initialView/types.ts Outdated
Comment on lines +1 to +6
/**
* Defines if the geoLocation button is rendered independent or as part of the
* icon menu.
* @defaultValue `'independent'`
*/

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/**
* Defines if the geoLocation button is rendered independent or as part of the
* icon menu.
* @defaultValue `'independent'`
*/

@JoselinGuevaraHoppe JoselinGuevaraHoppe Jul 31, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +11 to +15
export interface InitialViewPluginOptions extends PluginOptions {
renderType?: 'independent' | 'iconMenu'
startCenter?: [number, number]
startResolution?: number
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • 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 renderType like in GeoLocationPluginOptions should be added here.
  • startCenter is a required configuration option. Thus, it can always be retrieved from coreStore.configuration.startCenter
  • startResolution is an optional configuration option but it has a default value. Thusm it can always safely be retrieved from coreStore.configuration.startResolution

@JoselinGuevaraHoppe JoselinGuevaraHoppe Jul 31, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread src/core/types/plugin.ts
Comment on lines +28 to +30
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'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Classes, components and types / interfaces are commonly using PascalCase while other variables are using camelCase.

@JoselinGuevaraHoppe JoselinGuevaraHoppe Jul 31, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:hint="$t(($) => $.label.return, { ns: PluginId })"
icon="kern-icon--home"
tooltip-position="left"
@click="onClick"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@click="onClick"
@click="initialViewStore.returnToInitialView"

As the local function onClick only calls returnToInitialView, this remove bloat.

@JoselinGuevaraHoppe JoselinGuevaraHoppe Jul 31, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread src/client.ts
Comment on lines +66 to +71
enabledPlugins.includes('returnToInitialView') &&
ReturnToInitialView({
displayComponent: true,
layoutTag: 'TOP_RIGHT',
renderType: 'iconMenu',
}),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/client.ts
import Fullscreen from '@/plugins/fullscreen'
import GeoLocation from '@/plugins/geoLocation'
import IconMenu from '@/plugins/iconMenu'
import ReturnToInitialView from '@/plugins/initialView'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naming the import InitialView seems more fitting.

return {
startCenter,
startResolution,
returnToInitialView,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
returnToInitialView,
/** @alpha */
returnToInitialView,

Comment thread src/core/types/main.ts
iconMenu?: IconMenuPluginOptions

/** Configuration for iInitialView plugin. */
returnToInitialView?: InitialViewPluginOptions

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
returnToInitialView?: InitialViewPluginOptions
initialView?: InitialViewPluginOptions

Comment thread src/core/types/main.ts
/** Configuration for iconMenu plugin. */
iconMenu?: IconMenuPluginOptions

/** Configuration for iInitialView plugin. */

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/** Configuration for iInitialView plugin. */
/** Configuration for initialView plugin. */

@github-actions

Copy link
Copy Markdown
PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://Dataport.github.io/polar/pr-preview/pr-909/

Built to branch gh-pages at 2026-07-31 09:47 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

<PolarIconButton
:hint="$t(($) => $.label.return, { ns: PluginId })"
icon="kern-icon--home"
tooltip-position="left"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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'>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants