OpenLayers OpenLayers

Ticket #340 (closed feature: fixed)

Opened 2 years ago

Last modified 8 months ago

maxExtent interpretation

Reported by: tschaub Assigned to: tschaub
Priority: minor Milestone: 2.5 Release
Component: Map Version:
Keywords: Cc:
State:

Description

I see maxExtent having meaning in two contexts: map browsing (panning, zooming, etc) and tile requests.

I think there is reason to support several interpretations in each context. Currently, I would say maxExtent is interpreted "very loosely" with regard to map browsing and "strictly" with regard to tile requests. This is fine, and I see why it should be an option. I'd like to flesh out the other interpretations and suggest that they also be supported as options.

Interpretation: strict

Context: map browsing – the map extent (in the viewport) never strays beyond maxExtent for the base layer. This means that maxExtent is so strictly interpreted that it overrides resolutions (a map may not be able to be zoomed to all zooms).

Context: tile requests – if maxExtent does not wholly contain tile bounds (for overlay or base layer) a tile is not requested.

Interpretation: loose

Context: map browsing – a base layer's resolutions have precedence over maxExtent, but maxExtent is respected where possible. If the requested map extent falls outside maxExtent in any direction, the returned extent is adjusted by the difference. If the requested map extent is completely outside the maxExtent in any dimension, the returned extent is centered on maxExtent.

Context: tile requests – if the union of maxExtent and map extent does not wholly contain tile bounds (for overlay or base layer) a tile is not requested

Interpretation: very loose

Context: map browsing – the center of the map extent should not stray beyond maxExtent.

Context: tile request – don't think there is anything sensible to say here

Interpretation: ignored

Context: map browsing – maxExtent isn't considered in map browsing

Context: tile requests – tiles are requested without regard to maxExtent

I think it makes sense to allow at least a "strict" or "loose" interpretation on base layers and overlays. Though I gather that there is interest in keeping the "very loose" interpretation with regard to map browsing, from a purely aesthetic point of view, it makes for funky looking maps if you're always allowed to pan off the edge of your data.

The "loose" interpretation has the benefit of always filling the viewport with data.

The "strict" interpretation has the benefit of trying not to request more data than the server wants to dole out.

If you are used to dealing with global datasets, this might not seem like that big a deal. However, I would guess that most folks will be trying to create applications where at least on layer has an extent less than the others, and would like to be able to stop the map from being panned off the edge of their data.

Attachments

map_maxextent.patch (0.6 kB) - added by bartvde on 07/23/07 08:57:14.
Patch to prevent getting out of maxExtent in setCenter
restrictedExtent.patch (11.0 kB) - added by tschaub on 09/12/07 15:47:33.
restrict panning

Change History

10/11/06 13:36:52 changed by tschaub

Sorry, replace "wholly contain" above with "partially contain" (both places).

10/18/06 13:05:11 changed by euzuro

  • milestone set to 2.3 Release.

10/25/06 06:30:11 changed by euzuro

  • owner changed.
  • component changed from general to Map.

12/06/06 16:44:19 changed by euzuro

  • owner set to tschaub.

12/14/06 07:35:52 changed by euzuro

comment from Trond Michelsen from users@

I'm not totally convinced that this is the best way to do it. I think
I'd prefer if openlayers tried it's best to not let the viewport go
outside maxExtent at all - except when you've zoomed so far out that
the entire extent fits within the viewport.

12/14/06 12:15:49 changed by tschaub

I think Trond's comments are captured in the loose interpretation of maxExtent above.

12/22/06 15:56:55 changed by tschaub

  • milestone changed from 2.3 Release to 2.4 Release.

More discussion. (I will also submit a patch if someone confirms that it's worth the effort.)

12/28/06 20:04:16 changed by euzuro

  • milestone changed from 2.4 Release to 2.5 Release.

01/23/07 17:39:47 changed by openlayers

I guess it would be useful to have a key to allow all approaches. strict,loose, vloose, ignore are the key that can allow all combinations. Naturally not mandatory, actual solution as default. I vote Tim for patches! :-) ominoverde

07/20/07 09:19:24 changed by crschmidt

07/23/07 08:57:14 changed by bartvde

  • attachment map_maxextent.patch added.

Patch to prevent getting out of maxExtent in setCenter

07/23/07 09:00:35 changed by bartvde

I think in some situations I even want strict behaviour. The patch I attached is also for strict behaviour.

E.g. if the maps I have don't extend beyond maxExtent I don't want them to be shown in those areas at all, in which case I need strict.

The question is what to do with the behaviour in the map when zoom out is not possible anymore (because of the maxExtent) in strict behaviour, alert the user of the situation, or automatically shift the map so that he can reach the zoomlevel?

07/31/07 12:46:12 changed by tschaub

I have a new position on this. Since we already have a "very loose" interpretation of maxExtent, I think it's easiest to add a new property that controls pan/zoom behavior. I've been using a restrictedExtent property that gets interpreted "loosely" according to my definition above.

In terms of a "strict" interpretation, I don't think it works well with OL. For example, I don't think it makes sense that the resolution (or zoom if you must) of the map change with a window resize. We have a fixed set of resolutions - in my mind the map center is the other absolute. We can try hard to keep the extent within some defined bounds, but I think we should respect resolutions first and map center second.

A bit more on resolution/center: if a user is browsing map with viewport that is some percentage of the window width (say 100%) and they want to bookmark their position - I think they assume that when they return to that bookmarked location, the center and resolution are the same - regardless of the size of their browser window. Given a map with data that is resolution dependent (certain data only shown at certain resolutions), we get in to real trouble if one person says "I see layer X when I zoom to 10" and another person says "I see layer Y when I zoom to 10". This would occur on variable sized maps with a "strict" interpretation of maxExtent with regard to map browsing.

So, I'm in favor of respecting resolution/center and of adding a restrictedExtent property that gets interpreted "loosely" with regard to map browsing. This would leave the current behavior untouched. Then, it might make sense to revisit this at 3.0.

If nobody has any better proposal (patch), I'll add a patch for restrictedExtent for 2.5.

07/31/07 12:51:02 changed by tschaub

On additional comment - I now think of the maxExtent property as an anchoredCenter with regard to map browsing (it has a different interpretation with regard to tile requests). If you let anchoredCenter be the center of maxExtent, things make sense - the anchoredCenter never strays beyond the bounds of the viewport. I know this is largely semantic, but this is how I'll explain it to anybody who asks - ignore obvious interpretation of the name maxExtent, this is just a longhand way of calculating an anchored center for the map - the center of the bounds that you specify will not stray beyond the bounds of the viewport. Unconfused?

09/01/07 00:40:56 changed by crschmidt

Awaiting patch from Tim.

09/12/07 15:47:33 changed by tschaub

  • attachment restrictedExtent.patch added.

restrict panning

09/12/07 15:48:03 changed by tschaub

  • keywords set to review.

please review

09/12/07 15:54:29 changed by tschaub

Should mention that all tests pass in IE and FF.

09/12/07 22:03:36 changed by crschmidt

  • keywords changed from review to commit.

Great patch. Thanks. Go ahead to commit when you're ready.

09/13/07 11:27:36 changed by tschaub

  • keywords deleted.
  • status changed from new to closed.
  • resolution set to fixed.

(In [4261]) Give the map a restrictedExtent property. Setting this property to some bounds causes map navigation to be limited to those bounds. Depending on the resolution settings, the viewport may still display area outside the restricted extent - though it will be centered on the restricted extent in that case. Using a combination of restrictedExtent and maxResolution, you can limit map navigation to the extent of your data (or any arbitrary extent). See the restricted-extent.html example (closes #340).