OpenLayers OpenLayers

Ticket #344 (closed bug: fixed)

Opened 3 years ago

Last modified 3 years ago

Make sure a center point has been set on the map before trying to load overlays

Reported by: euzuro Assigned to: crschmidt
Priority: blocker Milestone: 2.2 Release
Component: Map Version: SVN
Keywords: Cc:
State:

Description

r1739

Back in addLayer() of Map.js,

when adding an overlay, we call getExtent() and if it has a value, we call moveTo() on the layer... essentially drawing it.

however, there is a fringe case (and maybe several) where when the baselayer is created and added to the map, even if the map has no center set, the baselayer *does*, and therefore is able to return a valid extent.

the case in point here is VE, who automaticallly loads to a bbox around the usa.

so heres the dig. current code does this:

            var extent = this.getExtent();
            if (extent) {
                layer.moveTo(extent, true);   
            }

we want it to do this:

            if (this.getCenter() != null) {
                layer.moveTo(this.getExtent(), true);   
            }

Attachments

testifcentered.patch (0.5 kB) - added by euzuro on 10/10/06 23:25:02.
patch that does what i say in the comment

Change History

10/10/06 23:25:02 changed by euzuro

  • attachment testifcentered.patch added.

patch that does what i say in the comment

10/10/06 23:26:04 changed by euzuro

  • owner deleted.

please review. i need this patch in for #342

10/11/06 05:45:49 changed by crschmidt

I'd need a more clear understanding of why this is a problem before I'd want to commit it.

If we have a maxExtent, we can determine a center. One of the things we discussed as a possibility was to not bomb out if users haven't called setCenter yet. It's not clear to me that this patch is heading in the right direction.

If we have a maxExtent, why can't we move the layer? It seems to me like we should be able to, so I must be missing something.

10/11/06 08:20:27 changed by euzuro

  • owner set to crschmidt.

if we want to make default behaviour dictate that the center is automatically set to the center of maxExtent, that is something worth discussing.

in the meantime, however, there exists a case where a baselayer can return a valid maxExtent() even though setCenter() has never called been called on the map.

A google layer won't exhibit this, because a getExtent() on a google layer returns null until a setCenter() has been called on the gmap object

With ve, however, it is different. when you call loadMap(), if you don't specify a staring lonlat, it just uses USA at a suitable zoom.... which is not really a problem but for the fact that when you call getExtent() it *will* return a valid extent.

and this even doesnt seem so grave but for the fact that we use this as a test to see if the map has been loaded.

since vemap returns a valid extent, this means that OL will try to render all the overlays immediately on addLayer(), even though the center has not been set.

This wont work, because for gridded layers, initTiles() requires the return from map.getCenter(), which will be null.

...entonces.... i need to put this little fix in.

10/11/06 08:40:50 changed by crschmidt

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

More discussion is needed on ways to reduce user interaction difficulties, but resolving that can be saved for v2.3, as mentioned in newly opened bug #345 .

Committed as r1743.

07/05/07 16:00:55 changed by euzuro

  • keywords deleted.