Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zoom property type of GeoMapView and layers must be a double #2701

Closed
Tracked by #672
Flaurite opened this issue Dec 28, 2023 · 0 comments
Closed
Tracked by #672

Zoom property type of GeoMapView and layers must be a double #2701

Flaurite opened this issue Dec 28, 2023 · 0 comments
Assignees
Labels
breaking changes Fix brings breaking changes in code or behavior in: maps size: S
Milestone

Comments

@Flaurite
Copy link
Contributor

Flaurite commented Dec 28, 2023

Feature Description

The zoom attribute from View object in OpenLayers can be non-integer. It is configured by the constrainResolution option (see View :: docs).

Also, see https://openlayers.org/en/latest/apidoc/module-ol_View-View.html#getZoom.

For instance, Vaadin add-on applies only double type for zoom level (see https://vaadin.com/docs/latest/components/map#events).

Changes

Changed type of zoom properties from Integer to Double.

  1. For VectorLayer, TileLayer, ImageLayer layers the following methods are affected:

    • getMinZoom()
    • setMinZoom()
    • withMinZoom()
    • getMaxZoom()
    • setMaxZoom()
    • withMaxZoom()
  2. For GeoMapView the following methods are affected:

    • getMinZoom()
    • setMinZoom()
    • withMinZoom()
    • getMaxZoom()
    • setMaxZoom()
    • withMaxZoom()
    • setZoom() - note, takes primitive double
    • getZoom() - note, returns primitive double

In XML according attributes changed to double type.

Breaking Changes

Due to changed type to Double, methods that work with zoom/minZoom/maxZoom are affected.

For instance, if you programmatically change the zoom properties of VectorLayer, TileLayer, ImageLayer or GeoMapView, the following code will not be compiled:

VectorLayer layer = new VectorLayer(); // any layer from above
layer.setMinZoom(5); // layer.withMinZoom(5);
layer.setMaxZoom(10); // layer.withMaxZoom(10);
Integer minZoom = layer.getMinZoom();
Integer maxZoom = layer.getMaxZoom();

GeoMapView mapView = new GeoMapView();
mapView.setMaxZoom(10);
mapView.setMinZoom(2);
Integer maxZoom = mapView.getMaxZoom();
Integer minZoom = mapView.getMinZoom();
int zoom = mapView.getZoom();

You should change integer values to double to fix a compilation.

Values defined in XML are loaded in correct way, thus using integer in XML does not break application.

Note, XyzSource and OsmSource takes Integer type for minZoom/maxZoom, otherwise component does not work.

@Flaurite Flaurite added breaking changes Fix brings breaking changes in code or behavior size: S in: maps labels Dec 28, 2023
@Flaurite Flaurite self-assigned this Dec 28, 2023
@Flaurite Flaurite changed the title Zoom property type of GeoMapView must be a double Zoom property type of GeoMapView and layers must be a double Dec 29, 2023
@gorbunkov gorbunkov added this to the 2.2.0 milestone Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking changes Fix brings breaking changes in code or behavior in: maps size: S
Projects
Status: Done
Development

No branches or pull requests

2 participants