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

View2D properties #818

Merged
merged 3 commits into from
Jun 25, 2013
Merged

View2D properties #818

merged 3 commits into from
Jun 25, 2013

Conversation

twpayne
Copy link
Contributor

@twpayne twpayne commented Jun 25, 2013

This PR improves the handling of default and missing values in ol.View2D, as suggested by @elemoine in #690.

@bbinet
Copy link
Member

bbinet commented Jun 25, 2013

Looks good to me.

@@ -89,7 +89,8 @@ ol.View2D = function(opt_options) {
values[ol.View2DProperty.RESOLUTION] = resolutionConstraint(
this.maxResolution_, options.zoom);
}
values[ol.View2DProperty.ROTATION] = options.rotation;
values[ol.View2DProperty.ROTATION] =
goog.isDef(options.rotation) ? options.rotation : 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good to me. Though I don't understand the above change. I was thinking that sanitization only occured in getView2DState.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question. This is for consistent behaviour with #690 regarding property values that are not explicitly set by the user.

Case for #690:

User creates a layer:

var layer = new ol.layer.Layer({
  source: ...
});

If default values are not set, then you get strange behaviour: layer.getVisible() returns undefined (which is logically false) but the layer is visible by default. Without explicitly setting a default value, you'll get undesired behaviour if you try to toggle a layer's visibility with

layer.setVisible(!layer.getVisible());

The easy (and, I think, least bad) solution is to explicitly set the default values of properties.

This change applies the same logic to rotation, so that, for example:

var view = new ol.View2D({});
view.setRotation(view.getRotation() + Math.PI / 4);

works as you'd expect.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Convinced. Thanks a lot for explaining.

twpayne added a commit that referenced this pull request Jun 25, 2013
@twpayne twpayne merged commit 38893ea into openlayers:master Jun 25, 2013
@twpayne twpayne deleted the view2d-properties branch June 25, 2013 11:50
afabiani pushed a commit to geosolutions-it/openlayers that referenced this pull request May 22, 2017
examples/vector-formats: Added "Encoded Polyline" format
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants