0

I have noticed that the Bing layer from OpenLayers disappears at low (0) and high (20) zoom levels. How could I avoid it? Is it possible to force some limit on the zoom levels?

var apiKey = "AqTGBsziZHIJYYxgivLBf0hVdrAk9mWO5cQcb8Yux8sW5M8c8opEC2lZqKR1ZZXf";
var map;

map = new OpenLayers.Map('map', {
    allOverlays: false,
    autoUpdateSize: true,
    displayProjection: new OpenLayers.Projection('EPSG:4326'),
    numZoomLevels: 16,
    projection: new OpenLayers.Projection('EPSG:900913'),
    zoomMethod: null,
    units: 'km'
});

map.addControl(new OpenLayers.Control.LayerSwitcher());

var osm = new OpenLayers.Layer.OSM();
var bing = new OpenLayers.Layer.Bing({
    name: "Road",
    key: apiKey,
    type: "Road"
});

map.addLayer(osm);
map.addLayer(bing);

var center = new OpenLayers.LonLat(-0.125, 51.5);
center.transform(new OpenLayers.Projection('EPSG:4326'), new OpenLayers.Projection('EPSG:900913'));
var zoomLevel = 4;
map.setCenter(center, zoomLevel);

$('#zoomLevel').html(zoomLevel);
map.events.register('zoomend', map, function() {
    $('#zoomLevel').html(this.zoom);
});

Here is my codepen and as you can test, this behaviour does not occur with the OSM layer. Please help me fix this.

Thanks

joaorodr84
  • 1,251
  • 2
  • 14
  • 33

1 Answers1

1

Bing Maps map tiles are only available at zoom levels 1 - 19. In Bing Maps zoom levels 20 and 21 are birds eye imagery which projected type of imagery not available in Open Layers. Zoom level 1 in Bing Maps is only 2 tiles wide. Zoom level 0 would be a single tile for the whole word which isn't used in Bing Maps.

rbrundritt
  • 16,570
  • 2
  • 21
  • 46
  • Thank you for theinformation @rbrundritt... but is there a way to stop at zoom levels 1 and 19 in order toavoid the unavailable zoom levels? – joaorodr84 Mar 04 '15 at 23:55
  • Take a look at this documentation: http://trac.osgeo.org/openlayers/wiki/SettingZoomLevels – rbrundritt Mar 05 '15 at 01:33
  • The numZoomLevel property helps avoiding the high unavailable zoom levels, but I still get stuck with the 0 zoom level... it seems that there is no way to start directly at zoom level 1 and block going to zoom level 0... but thanks anyway... :) – joaorodr84 Mar 05 '15 at 12:25
  • You could try using events to override the zoom levels like this: http://stackoverflow.com/questions/4240610/min-max-zoom-level-in-openlayers – rbrundritt Mar 05 '15 at 16:00