# OpenLayers.Layer.FixedZoomLevels

Some Layers will already have established zoom levels (like google or ve). Instead of trying to determine them and populate a resolutions[] Array with those values, we will hijack the resolution functionality here.

#### When you subclass FixedZoomLevels

The initResolutions() call gets nullified, meaning no resolutions[] array is set up. Which would be a big problem getResolution() in Layer, since it merely takes map.zoom and indexes into resolutions[]... but....

The getResolution() call is also overridden. Instead of using the resolutions[] array, we simply calculate the current resolution based on the current extent and the current map size. But how will we be able to calculate the current extent without knowing the resolution...?

The getExtent() function is also overridden. Instead of calculating extent based on the center point and the current resolution, we instead calculate the extent by getting the lonlats at the top-left and bottom-right by using the getLonLatFromViewPortPx() translation function, taken from the pixel locations (0,0) and the size of the map. But how will we be able to do lonlat-px translation without resolution....?

The getZoomForResolution() method is overridden. Instead of indexing into the resolutions[] array, we call OpenLayers.Layer.getExent(), passing in the desired resolution. With this extent, we then call getZoomForExtent()

Whenever you implement a layer using OpenLayers.Layer.FixedZoomLevels, it is your responsibility to provide the following three functions:

- getLonLatFromViewPortPx
- getViewPortPxFromLonLat
- getZoomForExtent

...those three functions should generally be provided by any reasonable API that you might be working from.

Summary

OpenLayers.Layer.FixedZoomLevels | Some Layers will already have established zoom levels (like google or ve).
Constructor |
OpenLayers.Layer.FixedZoomLevels | Create a new fixed zoom levels layer.
Functions |
initResolutions | Populate the resolutions array
getResolution | Get the current map resolution
getExtent | Calculates using px-> lonlat translation functions on tl and br corners of viewport
getZoomForResolution | Get the zoom level for a given resolution
getOLZoomFromMapObjectZoom | Get the OL zoom index from the map object zoom level
getMapObjectZoomFromOLZoom | Get the map object zoom level from the OL zoom level

### Constructor

### OpenLayers.Layer.FixedZoomLevels

Create a new fixed zoom levels layer.

### Functions

### initResolutions

> initResolutions: function()

Populate the resolutions array

### getResolution

> getResolution: function()

Get the current map resolution

#### Returns

{Float} Map units per Pixel

### getExtent

> getExtent: function ()

Calculates using px-> lonlat translation functions on tl and br corners of viewport

#### Returns

{OpenLayers.Bounds} A Bounds object which represents the lon/lat bounds of the current viewPort.

### getZoomForResolution

> getZoomForResolution: function( | resolution | )

Get the zoom level for a given resolution

#### Parameters

resolution | {Float}

#### Returns

{Integer} A suitable zoom level for the specified resolution. If no baselayer is set, returns null.

### getOLZoomFromMapObjectZoom

> getOLZoomFromMapObjectZoom: function( | moZoom | )

Get the OL zoom index from the map object zoom level

#### Parameters

moZoom | {Integer}

#### Returns

{Integer} An OpenLayers Zoom level, translated from the passed in zoom Returns null if null value is passed in

### getMapObjectZoomFromOLZoom

> getMapObjectZoomFromOLZoom: function( | olZoom | )

Get the map object zoom level from the OL zoom level

#### Parameters

olZoom | {Integer}

#### Returns

{Integer} A MapObject level, translated from the passed in olZoom Returns null if null value is passed in

> initResolutions: function()

Populate the resolutions array

> getResolution: function()

Get the current map resolution

> getExtent: function ()

Calculates using px-> lonlat translation functions on tl and br corners of viewport

> getZoomForResolution: function( | resolution | )

Get the zoom level for a given resolution

> getOLZoomFromMapObjectZoom: function( | moZoom | )

Get the OL zoom index from the map object zoom level

> getMapObjectZoomFromOLZoom: function( | olZoom | )

Get the map object zoom level from the OL zoom level
Instances of this class represent bounding boxes.
Close