0

I am using different types of base layer in OpenLayers and drawing vector layers on them. I am having trouble with Google satellite base layers.

I have noticed that satellite view has different zoom levels in different places. In some places base layer is not zooming but vector layer is zooming.

How can I determine if farther zoom level is available for a certain base layer?

In the images bellow a corner is marked with red. Notice the change position of the vector layer
Zoom level 19
Vector at zoom level 19

Zoom level 20
Same vector at zoom level 20

1 Answer 1

1

One thing you can do if you have base layers with different resolutions is to detect for the layer in the changebaselayer callback and then reset the map's resolutions array, and redraw the panzoombar control, so it can only zoom to the new base layer's resolutions.

map.events.register("changebaselayer", this, function (obj) {
    if (obj.layer.name == 'your_layer_name') {
        map.baseLayer.resolutions = [20, 10, 5];
        map.baseLayer.numZoomLevels = 3;
        map.baseLayer.fractionalZoom = false;
        map.baseLayer.maxResolution = 20;
        map.baseLayer.minResolution = 5;
        map.zoomTo(2, map.getCenter());
        panzoombar.redraw();
    }
});

In other words, you need to have different resolutions arrays if you are using layer with different allowed resolutions. These should be preloaded at design time, as you can't easily detect if a particular layer allows a certain zoom from the client.

4
  • Well, how do I know what resolutions array to use? Also, satellite layer has different max zoom in different places.
    – Mohayemin
    Commented Oct 27, 2014 at 9:22
  • You have to know the resolutions array before you can sensible add any layer with fixed zoom levels. Different zooms at different areas makes things a bit complicated. Presumably, Google Maps uses a spatial lookup. I'm not sure how you could do it from OpenLayers without knowing which areas have different zooms. You might have another issue also, as you can always zoom a layer (and get a very pixelated image back), but your tiles and vector layers shouldn't get out of sync like this. Commented Oct 27, 2014 at 9:42
  • The resolutions for GM can be seen here: trac.osgeo.org/openlayers/browser/trunk/openlayers/lib/…. You might want to add transitionEffect: 'resize' to map constructor as well. Commented Oct 27, 2014 at 9:49
  • Your answer did not solve my problem but I figured out the "Google Maps uses a spatial lookup" which you mentioned in your comment. I understand that what I need cannot be done only with OpenLayers. I need help of Maximum Zoom Imagery Service. I am trying it. Thanks.
    – Mohayemin
    Commented Oct 28, 2014 at 6:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.