Ticket #2397 (closed feature: invalid)

Opened 3 years ago

Last modified 3 years ago

Improve init sequence for late rendering

Reported by: ahocevar Owned by:
Priority: minor Milestone: 2.9 Release
Component: Map Version: SVN
Keywords: Cc:
State:

Description

The init sequence for late rendering tends to cause errors with setting size of commercial layers, setting base layers and maxExtent. I am proposing a new init sequence with the following changes:

  • Do not initialize most of the map when constructur is called without a div.
  • While the map is unrendered, adding and removing controls and layers works, but add events won't be triggered before the map is rendered. Other interaction with the map is discouraged until properly rendered.
  • Add a "render" event to the map and a "setmap" event to Layer and Control.

Examples still work, but I had to modify some tests where the map was initialized without a div or with a dom element instead of an id. With these modifications, all tests pass.

Attachments

openlayers-initsequence.patch Download (12.3 KB) - added by ahocevar 3 years ago.
openlayers-initsequence.1.patch Download (13.9 KB) - added by fredj 3 years ago.
Google.display() crash with unrendered map (tries to access this.termsOfUse and this.poweredBy)
openlayers-initsequence.2.patch Download (14.9 KB) - added by fredj 3 years ago.
fixes the google size issue by calling this.onMapResize in Layer.setVisibility (maybe not the best place to do it but it works)

Change History

Changed 3 years ago by ahocevar

Changed 3 years ago by fredj

Google.display() crash with unrendered map (tries to access this.termsOfUse and this.poweredBy)

Changed 3 years ago by fredj

  • state changed from Review to Needs More Work

Still an issue with the size of a google layer:

var map = new OpenLayers.Map();
var layer = new OpenLayers.Layer.Google('Goog Layer');
map.addLayer(layer);

map.render("map");
map.zoomToMaxExtent();
var size = layer.mapObject.getSize();
t.ok(size.width > 0, "layer width is correct");
t.ok(size.height > 0, "layer height is correct");

onMapResize is never called for this layer.

Changed 3 years ago by fredj

fixes the google size issue by calling this.onMapResize in Layer.setVisibility (maybe not the best place to do it but it works)

Changed 3 years ago by ahocevar

  • status changed from new to closed
  • resolution set to invalid

closing, too many negative side effects.

Changed 3 years ago by ahocevar

  • state Needs More Work deleted
Note: See TracTickets for help on using tickets.