Skip to content

Commit

Permalink
Update zoom correctly when requesting link to configuration
Browse files Browse the repository at this point in the history
Before, zoom value was ignored in view, but was present in the url, when user requested a link to current configuration. This commit makes zoomToBound() apply changes to zoom, when parameters are present. Parameters are present if the url with zoom, lon, lat values is present, ie when user requests link to current configuration.
  • Loading branch information
podliashanyk committed Nov 3, 2022
1 parent b477577 commit 1bbd660
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions python/nav/web/static/js/geomap/GeomapPlugin.js
Expand Up @@ -135,6 +135,22 @@ function(Spinner, fullscreen) {
var requestedBounds = OpenLayers.Bounds.fromArray(parameters.bbox);
requestedBounds.transform(map.displayProjection, map.getProjectionObject());
map.zoomToExtent(requestedBounds);
} else if (parameters.zoom !== null && parameters.zoom !== undefined) {
try {
if (parameters.lat !== null && parameters.lat !== undefined
&& parameters.lon !== null && parameters.lon !== undefined) {
map.setView(
new OpenLayers.View({
center: OpenLayers.Projection.fromLonLat([parameters.lon, parameters.lat]),
extent: map.getView().calculateExtent(map.getSize()),
zoom: parameters.zoom
})
);
} else {
map.getView.setZoom(parameters.zoom);
}
map.getView.setZoom(parameters.zoom);
} catch (e) {}
} else if (boundingBox) {
boundingBox.transform(map.displayProjection, map.getProjectionObject());
map.zoomToExtent(boundingBox);
Expand Down

0 comments on commit 1bbd660

Please sign in to comment.