openlayers: Cannot modify ol.View constraints
I have what might be a unique situation, but I find it a little surprising no one’s brought this up as an issue before.
In my application, we have a small map with some build in edit tools, and a simple vector layer. The idea is that this view is constrained to just the extent of the visible features, plus a bit of padding. So far, so good; ol.View does that with the extent option.
However, these are individual fields a farmer has; typically most farmers have a lot (between 50 and 1500) fields. We want to be able to scroll through those, as opposed to make the farmer click on each field to edit it. That’s not a big deal; I clear the vector layer, add the new features and… now I’m stuck. I have no way to change the ol.View center constraint. My work around is to rebuild the ol.View every time we scroll. This feels very messy, and it feels like there should be a simple way to create new constraints; looking at the code it could be as simple as having the following setters: setExtent(), setMaxZoom(), setMinZoom(), setConstrainRotation(), enableRotation(), disableRotation().
Is there any reason not to add these?
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Reactions: 4
- Comments: 16 (10 by maintainers)
Commits related to this issue
- Added missing constrain setters from ol.View This adds several missing constrain setters from ol.View, and fixes #3913. Tests and example to come. — committed to Morgul/openlayers by Morgul 6 years ago
- Added missing constrain setters from ol.View This adds several missing constrain setters from ol.View, and fixes #3913. Tests and example to come. — committed to Morgul/openlayers by Morgul 6 years ago
@fredj @ahocevar Basically, same question as my last comment? What are the dev’s thoughts/feelings on this? I put in a PR a while ago that just needed some unit tests… and the current work around is very sub-optimal.
@fredj this feature is very useful and a PR already exists, may be adding a
pull request acceptedlabel will avoid the auto closing of the issue. And it will encourage @morgul or someone else to finish his PR.