2

I was trying to obtain maximum zoom level ( level 22) for Google street map using Openlayers.layer.google script.

The following code does not seem to work. It works to the maximum zoom level when the zoom variable is set to 15, but below or above 15, it sets centre to world extent.

Any idea what went wrong? we tried using Google maps API v2 and v3, same result for Maxmimum zoom, except for value = 15.

var position = new OpenLayers.LonLat(lon, lat).transform(fromProjection, toProjection);
var zoom = 22;
map.setCenter(position, zoom);
4

You need to configure your Google layer with an appropriate numZoomLevels value, and also override the internal default for the maximum zoom level with MAX_ZOOM_LEVEL. The latter will cause unexpected behavior if the Google layer does not support all zoom levels.

new OpenLayers.Layer.Google('Satellite', {
    type: google.maps.MapTypeId.SATELLITE,
    numZoomLevels: 23,
    MAX_ZOOM_LEVEL: 22
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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