Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

In my app user starts with empty map and can dynamically add new layers. When user adds new layer i do the following:

  1. send request to geoserver for layer capability to get layer extent.
  2. zoom to received extent via map.zoomToExtent(bounds)
  3. add layer to openlayers map.

Everything works fine but i have one problem. As my map is configured with allOverlays i have no baseLayer. When user adds first layer to map, the zoomToExtent function returns TypeError: this.baseLayer is null.

When i add a dummy layer: new OpenLayers.Layer("Dummy", {isBaseLayer: false}); everything works.

I really dont want to add any dummy layers. Any ideas why i cannot zoom empty map to provided bounds? Map has maxExtent configured properly.

share|improve this question
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.