OpenLayers.
|
|
Properties | |
id | {String} |
name | {String} |
div | {DOMElement} |
opacity | {Float} The layer’s opacity. |
alwaysInRange | {Boolean} If a layer’s display should not be scale-based, this should be set to true. |
Constants | |
RESOLUTION_PROPERTIES | {Array} The properties that are used for calculating resolutions information. |
Properties | |
events | {OpenLayers.Events} |
map | {OpenLayers.Map} This variable is set when the layer is added to the map, via the accessor function setMap(). |
isBaseLayer | {Boolean} Whether or not the layer is a base layer. |
displayInLayerSwitcher | {Boolean} Display the layer’s name in the layer switcher. |
visibility | {Boolean} The layer should be displayed in the map. |
attribution | {String} Attribution string, displayed when an OpenLayers.Control.Attribution has been added to the map. |
eventListeners | {Object} If set as an option at construction, the eventListeners object will be registered with OpenLayers.Events.on. |
gutter | {Integer} Determines the width (in pixels) of the gutter around image tiles to ignore. |
projection | {OpenLayers.Projection} or {String} Specifies the projection of the layer. |
units | {String} The layer map units. |
scales | {Array} An array of map scales in descending order. |
resolutions | {Array} A list of map resolutions (map units per pixel) in descending order. |
maxExtent | {<OpenLayers.Bounds>|Array} If provided as an array, the array should consist of four values (left, bottom, right, top). |
minExtent | {<OpenLayers.Bounds>|Array} If provided as an array, the array should consist of four values (left, bottom, right, top). |
maxResolution | {Float} Default max is 360 deg / 256 px, which corresponds to zoom level 0 on gmaps. |
minResolution | {Float} |
numZoomLevels | {Integer} |
minScale | {Float} |
maxScale | {Float} |
displayOutsideMaxExtent | {Boolean} Request map tiles that are completely outside of the max extent for this layer. |
wrapDateLine | {Boolean} Wraps the world at the international dateline, so the map can be panned infinitely in longitudinal direction. |
Constructor | |
OpenLayers.
|
|
Functions | |
setName | Sets the new layer name for this layer. |
addOptions | |
onMapResize | This function can be implemented by subclasses |
redraw | Redraws the layer. |
removeMap | Just as setMap() allows each layer the possibility to take a personalized action on being added to the map, removeMap() allows each layer to take a personalized action on being removed from it. |
getImageSize | |
setTileSize | Set the tile size based on the map size. |
getVisibility | {Boolean} The layer should be displayed (if in range). |
setVisibility | Set the visibility flag for the layer and hide/show & redraw accordingly. |
display | Hide or show the Layer. |
calculateInRange | {Boolean} The layer is displayable at the current map’s current resolution. |
setIsBaseLayer | |
getResolution | {Float} The currently selected resolution of the map, taken from the resolutions array, indexed by current zoom level. |
getExtent | {OpenLayers.Bounds} A Bounds object which represents the lon/lat bounds of the current viewPort. |
getZoomForExtent | |
getResolutionForZoom | |
getZoomForResolution | |
getLonLatFromViewPortPx | |
getViewPortPxFromLonLat | Returns a pixel location given a map location. |
setOpacity | Sets the opacity for the entire layer (all images) |
{Boolean} If a layer’s display should not be scale-based, this should be set to true. This will cause the layer, as an overlay, to always be ‘active’, by always returning true from the calculateInRange() function.
If not explicitly specified for a layer, its value will be determined on startup in initResolutions() based on whether or not any scale-specific properties have been set as options on the layer. If no scale-specific options have been set on the layer, we assume that it should always be in range.
See #987 for more info.
layer.events.register(type, obj, listener);
Listeners will be called with a reference to an event object. The properties of this event depends on exactly what happened.
object | {Object} A reference to layer.events.object. |
element | {DOMElement} A reference to layer.events.element. |
loadstart | Triggered when layer loading starts. When using a Vector layer with a Fixed or BBOX strategy, the event object includes a filter property holding the OpenLayers.Filter used when calling read on the protocol. |
loadend | Triggered when layer loading ends. When using a Vector layer with a Fixed or BBOX strategy, the event object includes a response property holding an OpenLayers.Protocol.Response object. |
visibilitychanged | Triggered when the layer’s visibility property is changed, e.g. by turning the layer on or off in the layer switcher. Note that the actual visibility of the layer can also change if it gets out of range (see calculateInRange). If you also want to catch these cases, register for the map’s ‘changelayer’ event instead. |
move | Triggered when layer moves (triggered with every mousemove during a drag). |
moveend | Triggered when layer is done moving, object passed as argument has a zoomChanged boolean property which tells that the zoom has changed. |
added | Triggered after the layer is added to a map. Listeners will receive an object with a map property referencing the map and a layer property referencing the layer. |
removed | Triggered after the layer is removed from the map. Listeners will receive an object with a map property referencing the map and a layer property referencing the layer. |
{OpenLayers.Map} This variable is set when the layer is added to the map, via the accessor function setMap().
{String} Attribution string, displayed when an OpenLayers.Control.Attribution has been added to the map.
{Object} If set as an option at construction, the eventListeners object will be registered with OpenLayers.Events.on. Object structure must be a listeners object as shown in the example for the events.on method.
{Integer} Determines the width (in pixels) of the gutter around image tiles to ignore. By setting this property to a non-zero value, images will be requested that are wider and taller than the tile size by a value of 2 x gutter. This allows artifacts of rendering at tile edges to be ignored. Set a gutter value that is equal to half the size of the widest symbol that needs to be displayed. Defaults to zero. Non-tiled layers always have zero gutter.
{OpenLayers.Projection} or {String} Specifies the projection of the layer. Can be set in the layer options. If not specified in the layer options, it is set to the default projection specified in the map, when the layer is added to the map. Projection along with default maxExtent and resolutions are set automatically with commercial baselayers in EPSG:3857, such as Google, Bing and OpenStreetMap, and do not need to be specified. Otherwise, if specifying projection, also set maxExtent, maxResolution or resolutions as appropriate. When using vector layers with strategies, layer projection should be set to the projection of the source data if that is different from the map default.
Can be either a string or an OpenLayers.Projection object; if a string is passed, will be converted to an object when the layer is added to the map.
{Array} An array of map scales in descending order. The values in the array correspond to the map scale denominator. Note that these values only make sense if the display (monitor) resolution of the client is correctly guessed by whomever is configuring the application. In addition, the units property must also be set. Use resolutions instead wherever possible.
{<OpenLayers.Bounds>|Array} If provided as an array, the array should consist of four values (left, bottom, right, top). The maximum extent for the layer. Defaults to null.
The center of these bounds will not stray outside of the viewport extent during panning. In addition, if displayOutsideMaxExtent is set to false, data will not be requested that falls completely outside of these bounds.
{Float} Default max is 360 deg / 256 px, which corresponds to zoom level 0 on gmaps. Specify a different value in the layer options if you are not using the default OpenLayers.Map.tileSize and displaying the whole world.
addOptions: function ( newOptions, reinitialize )
newOptions | {Object} |
reinitialize | {Boolean} If set to true, and if resolution options of the current baseLayer were changed, the map will be recentered to make sure that it is displayed with a valid resolution, and a changebaselayer event will be triggered. |
removeMap: function( map )
Just as setMap() allows each layer the possibility to take a personalized action on being added to the map, removeMap() allows each layer to take a personalized action on being removed from it. For now, this will be mostly unused, except for the EventPane layer, which needs this hook so that it can remove the special invisible pane.
map | {OpenLayers.Map} |
getImageSize: function( bounds )
bounds | {OpenLayers.Bounds} optional tile bounds, can be used by subclasses that have to deal with different tile sizes at the layer extent edges (e.g. Zoomify) |
{OpenLayers.Size} The size that the image should be, taking into account gutters.
setTileSize: function( size )
Set the tile size based on the map size. This also sets layer.imageSize or use by Tile.Image.
size | {OpenLayers.Size} |
setVisibility: function( visibility )
Set the visibility flag for the layer and hide/show & redraw accordingly. Fire event unless otherwise specified
Note that visibility is no longer simply whether or not the layer’s style.display is set to “block”. Now we store a ‘visibility’ state property on the layer class, this allows us to remember whether or not we desire for a layer to be visible. In the case where the map’s resolution is out of the layer’s range, this desire may be subverted.
visibility | {Boolean} Whether or not to display the layer (if in range) |
getExtent: function()
{OpenLayers.Bounds} A Bounds object which represents the lon/lat bounds of the current viewPort.
getZoomForExtent: function( extent, closest )
extent | {OpenLayers.Bounds} |
closest | {Boolean} Find the zoom level that most closely fits the specified bounds. Note that this may result in a zoom that does not exactly contain the entire extent. Default is false. |
{Integer} The index of the zoomLevel (entry in the resolutions array) for the passed-in extent. We do this by calculating the ideal resolution for the given extent (based on the map size) and then calling getZoomForResolution(), passing along the ‘closest’ parameter.
getZoomForResolution: function( resolution, closest )
resolution | {Float} |
closest | {Boolean} Find the zoom level that corresponds to the absolute closest resolution, which may result in a zoom whose corresponding resolution is actually smaller than we would have desired (if this is being called from a getZoomForExtent() call, then this means that the returned zoom index might not actually contain the entire extent specified... but it’ll be close). Default is false. |
{Integer} The index of the zoomLevel (entry in the resolutions array) that corresponds to the best fit resolution given the passed in value and the ‘closest’ specification.
getLonLatFromViewPortPx: function ( viewPortPx )
viewPortPx | {<OpenLayers.Pixel>|Object} An OpenLayers.Pixel or an object with a ‘x’ and ‘y’ properties. |
{OpenLayers.LonLat} An OpenLayers.LonLat which is the passed-in view port OpenLayers.Pixel, translated into lon/lat by the layer.
getViewPortPxFromLonLat: function ( lonlat, resolution )
Returns a pixel location given a map location. This method will return fractional pixel values.
lonlat | {<OpenLayers.LonLat>|Object} An OpenLayers.LonLat or an object with a ‘lon’ and ‘lat’ properties. |
{OpenLayers.Pixel} An OpenLayers.Pixel which is the passed-in lonlat translated into view port pixels.
Convenience method for registering listeners with a common scope.
on: function( object )
Sets the new layer name for this layer.
setName: function( newName )
addOptions: function ( newOptions, reinitialize )
This function can be implemented by subclasses
onMapResize: function()
Redraws the layer.
redraw: function()
Just as setMap() allows each layer the possibility to take a personalized action on being added to the map, removeMap() allows each layer to take a personalized action on being removed from it.
removeMap: function( map )
getImageSize: function( bounds )
Set the tile size based on the map size.
setTileSize: function( size )
{Boolean} The layer should be displayed (if in range).
getVisibility: function()
Set the visibility flag for the layer and hide/show & redraw accordingly.
setVisibility: function( visibility )
Hide or show the Layer.
display: function( display )
{Boolean} The layer is displayable at the current map’s current resolution.
calculateInRange: function()
setIsBaseLayer: function( isBaseLayer )
{Float} The currently selected resolution of the map, taken from the resolutions array, indexed by current zoom level.
getResolution: function()
{OpenLayers.Bounds} A Bounds object which represents the lon/lat bounds of the current viewPort.
getExtent: function()
getZoomForExtent: function( extent, closest )
getResolutionForZoom: function( zoom )
getZoomForResolution: function( resolution, closest )
getLonLatFromViewPortPx: function ( viewPortPx )
Returns a pixel location given a map location.
getViewPortPxFromLonLat: function ( lonlat, resolution )
Sets the opacity for the entire layer (all images)
setOpacity: function( opacity )