Skip to content
Snippets Groups Projects

feat(bounds): plugins bounds (MIN-228)

Merged mateusz-winiarczyk requested to merge MIN-228-plugin-bounds into development
4 unresolved threads

Bounds

Get Bounds

To get bounds of the current active map, plugins can use the getBounds method defined in window.minerva.map.data object available globally. It returns object with properties x1, y1, x2, y2

  • x1, y1 - top left corner coordinates
  • x2, y2 - right bottom corner coordinates

Example of returned object:

{
  x1: 12853,
  y1: 4201,
  x2: 23327,
  y2: 9575
}
Example of getBounds method usage:
window.minerva.map.data.getBounds();

Fit bounds

To zoom in the map in a way that rectangle defined by coordinates is visible, plugins can use the fitBounds method defined in window.minerva.map object available globally. This method takes one argument: object with properties x1, y1, x2, y2.

  • x1, y1 - top left corner coordinates
  • x2, y2 - right bottom corner coordinates
Example of fitBounds method usage:
window.minerva.map.fitBounds({
  x1: 14057.166666666668,
  y1: 6805.337365980873,
  x2: 14057.166666666668,
  y2: 6805.337365980873,
});

In addition to the bounds functionality for plugins, support for fitBounds param in window.minerva.map.triggerSearch has also been added. When param is true, after searching by coordinates or query, the map is zoomed to the results. Now everything should work correctly as described in plugins/search.md

In addition, the getOpenMapId method has been added. After consulting with Piotr, we no longer provide modelId in fitBounds/getBounds, but the plugin user must be able to check what map is currently open to know which map the coordinates belong to.

getOpenMapId
getOpenMapId

fitBounds and getBounds
fitboundsgetbounds

triggerSearch by query - fitBounds: true
triggerSearch-fitbounds

triggerSearch by query - fitBounds: false
triggersearch_fit_bounds_false_-2

triggerSearch by coordinates - fitBounds: true
triggerSearch_-_fitbounds2

triggerSearch by coordinates - fitBounds: false
triggerSearch_-_fitbounds_false

Closes MIN-228

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
14 15 searchQueries: [id.toString()],
15 16 isPerfectMatch: true
16 17 }),
17 );
18 )
19 .unwrap().then(() => {
20 if (hasFitBounds) {
21 searchFitBounds(fitBoundsZoom);
22 }
23 }).catch(() => {
24 // TODO to discuss manage state of failure
  • 28 29 getMultiBioEntity({
    29 30 searchQueries: bioEntitiesIds,
    30 31 isPerfectMatch: true },
    31 ),
    32 );
    32 )
    33 ).unwrap().then(() => {
    34 if (hasFitBounds) {
    35 searchFitBounds(fitBoundsZoom);
    36 }
    37 }).catch(() => {
    38 // TODO to discuss manage state of failure
  • mateusz-winiarczyk changed title from Resolve MIN-228 "Plugin bounds" to feat(bounds): plugins bounds (MIN-228)

    changed title from Resolve MIN-228 "Plugin bounds" to feat(bounds): plugins bounds (MIN-228)

  • 42 43 });
    43 44
    44 45 setMapInstance(currentMap => currentMap || map);
    46 if (!MapManager.mapInstance) {
    47 MapManager.setMapInstance(map);
    48 }
  • 23 getStateMock.mockImplementation(
    24 () =>
    25 ({
    26 map: {
    27 ...initialMapStateFixture,
    28 data: {
    29 ...initialMapStateFixture.data,
    30 modelId: null,
    31 },
    32 },
    33 // eslint-disable-next-line @typescript-eslint/no-explicit-any
    34 }) as any,
    35 );
    36
    37 expect(() => getOpenMapId()).toThrowError(
    38 'Unable to retrieve the ID of the active map: the modelId is not a number.',
  • LGTM, 1 RFC

  • Adrian Orłów approved this merge request

    approved this merge request

  • mateusz-winiarczyk added 16 commits

    added 16 commits

    • e966ba1b...1bfc48af - 14 commits from branch development
    • a8b51b52 - refactor(mapinstance): fix doubling state and mapinstance provider and map manager have sync value
    • a306d5c9 - Merge remote-tracking branch 'origin/development' into MIN-228-plugin-bounds

    Compare with previous version

  • added 1 commit

    • 1e615a3f - refactor(pluginerrors): extract plugin errors to variables and add description in docs

    Compare with previous version

  • added 1 commit

    • a17d937b - fix(docs): fix displaying submaps docs

    Compare with previous version

  • mentioned in commit c8418366

  • Please register or sign in to reply
    Loading