joaorodr84
joaorodr84

Reputation: 1312

Why does the OpenLayers Bing Layer disappear at low/high zoom levels?

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

Upvotes: 0

Views: 989

Answers (1)

rbrundritt
rbrundritt

Reputation: 17954

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.

Upvotes: 1

Related Questions