0

I can't seem to find a solution to allow panning or zooming when a vector layer polygon fills the entire map area. My current solution is to use the zoom out button to zoom out far enough to find an open area of the map to click on to pan and zoom. Is there a way to propagate the pan/zoom capabilities through the vector layer features?

Shows multiple features that take up the entire map space.

Even in the OL code (https://github.com/openlayers/openlayers/blob/v6.5.0/src/ol/control/Zoom.js), I don't see any reference to vector layers preventing zooming:

zoomByDelta_(delta) {
    const map = this.getMap();
    const view = map.getView();
    if (!view) {
      // the map does not have a view, so we can't act
      // upon it
      return;
    }
    const currentZoom = view.getZoom();
    if (currentZoom !== undefined) {
      const newZoom = view.getConstrainedZoom(currentZoom + delta);
      if (this.duration_ > 0) {
        if (view.getAnimating()) {
          view.cancelAnimations();
        }
        view.animate({
          zoom: newZoom,
          duration: this.duration_,
          easing: easeOut,
        });
      } else {
        view.setZoom(newZoom);
      }
    }
  }
}
1
  • 1
    It's unclear what you mean by "allow panning or zooming when a vector layer polygon fills the entire map area". Please edit your question and explain a bit more. Why wouldn't panning and zooming be allowed by default? You can zoom as much as you want, up to max view zoom, and you can pan as much as you want, unless you have some constraint. Nothing of this is mentioned in your question.
    – TomazicM
    May 5 at 17:22
0

It turns out that I had an older version of ol-popup.js which was causing the issue. Once @TomazicM didn't understand what I meant it became clear that it wasn't an OpenLayers issue as much as it was a library. I feel a bit dumb that I didn't realize this. Thanks for the assist as it led me down the right path. I've learned a lot from this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.