Skip to content

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

mateusz-winiarczyk requested to merge MIN-228-plugin-bounds into development

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