nav
nav copied to clipboard
[BUG] Geomap link to this configuration leads to default map
Describe the bug When using the geomap functionality "link to this configuration" a link is created with the correct parameters, but when following that link it always leads to the default map instead of the specific configuration, even though the time interval is correctly configured.
To Reproduce Steps to reproduce the behavior:
- Go to Geomap. Configure the map in some way (zoom into a specific part).
- Click on 'Map options' and 'Link to this configuration'.
- See that is loads the default map.
Environment:
- Ubuntu 20.04, Firefox 100.0 (64-bit)
This was first noticed in https://github.com/Uninett/nav/pull/2408
After inspecting the code and trying to figure out where things go wrong I realized that there is no implemented functionality that reads the longitude, latitude and zoom from the URL parameters and changes the map accordingly.
The bug is reproduced for macOS Monterey 12.4 in:
- Chrome 104.0
- Safari 15.5
- Firefox 103.0
NB! There is one correction to the original report: bug does not exactly lead to the loading of the default map. The map that loads has correct lat (latitude) and lon (longitude) representation, the only parameter that is not represented correctly is zoom (zoom is always set to default, which is 3, after linking to configuration).
The reason bug occurs is due to boundingBox in GeomapPlugin.js being always null. When it is null, the zoomToBounds() function defaults to executing the else-block, which performs zooming the map to max extent. Interestingly, zoomToBounds() receives the correct zoom, lat and lon values, but does not apply those values. The anticipated solution is to assign not-null value to boundingBox.