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

Determine image size on load #2796

Merged
merged 4 commits into from Oct 12, 2014
Merged

Determine image size on load #2796

merged 4 commits into from Oct 12, 2014

Conversation

tschaub
Copy link
Member

@tschaub tschaub commented Oct 5, 2014

This makes it so the image size does have to be provided for static image sources. If not provided, the size is determined when the image loads.

If a ol.source.ImageStatic is constructed without an imageSize option, the source is given the "loading" state and image loading is triggered. When the image loads, the image resolution is calculated, and the source is given the "ready" state.

Fixes #2767.

@elemoine elemoine added this to the v3.1.0 milestone Oct 8, 2014
projection: projection,
resolutions: [imageResolution]
projection: ol.proj.get(options.projection),
resolutions: resolutions,
Copy link
Member

Choose a reason for hiding this comment

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

If no image size was provided in the options passed to the constructor then undefined will be passed the parent constructor for the resolutions option. Looking at the code I don't think this a problem, because ol.source.ImageStatic doesn't use ol.source.Image#findNearestResolution. For clarity it may make sense to not pass resolutions to the parent constructor.

@elemoine
Copy link
Member

elemoine commented Oct 8, 2014

It looks good to me. I just added three pretty minor comments.

Also, with this change, the ImageStatic constructor itself loads the image if no image size was provided in the constructor options. Initially the renderer was the only one responsible for loading images, which means images were loaded at only one place in the code. But I'm wondering why we need that the constructor load the image? Why don't we let the renderer do it as previously? This would avoid the handling of source states in ImageStatic.

@tschaub
Copy link
Member Author

tschaub commented Oct 12, 2014

But I'm wondering why we need that the constructor load the image?

Indeed we don't. See 4979609.

Thanks for the review.

@elemoine
Copy link
Member

Please merge.

tschaub added a commit that referenced this pull request Oct 12, 2014
Determine image size on load.
@tschaub tschaub merged commit 6fdc35e into openlayers:master Oct 12, 2014
@tschaub tschaub deleted the lazy-size branch October 12, 2014 16:31
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.

Allow use of static image source without knowing image size
2 participants