Namespace: ol

ol

Classes

Attribution
Collection
CollectionEvent
DeviceOrientation
DragBoxEvent
Feature
FeatureOverlay
Geolocation
Graticule
Image
ImageBase
ImageTile
Kinetic
Map
MapBrowserEvent
MapEvent
Object
ObjectEvent
Observable
Overlay
SelectEvent
Sphere
Tile
View
View2D

Namespaces

animation
color
control
coordinate
easing
events
extent
featureloader
format
geom
has
interaction
layer
loadingstrategy
proj
render
source
style
tilegrid

Methods

ol.inherits(childCtor, parentCtor) experimental

src/ol/ol.js, line 240

Inherit the prototype methods from one constructor into another.

Usage:

function ParentClass(a, b) { }
ParentClass.prototype.foo = function(a) { }

function ChildClass(a, b, c) {
  // Call parent constructor
  ParentClass.call(this, a, b);
}
ol.inherits(ChildClass, ParentClass);

var child = new ChildClass('a', 'b', 'see');
child.foo(); // This works.

In addition, a superclass' implementation of a method can be invoked as follows:

ChildClass.prototype.foo = function(a) {
  ChildClass.base(this, 'foo', a);
  // Other code here.
};
Name Type Description
childCtor function

Child constructor.

parentCtor function

Parent constructor.

Type Definitions

ol.CanvasFunctionType() experimental

src/ol/canvasfunction.js, line 17

A function returning the canvas element ({HTMLCanvasElement}) used by the source as an image. The arguments passed to the function are: ol.Extent the image extent, {number} the image resolution, {number} the device pixel ratio, ol.Size the image size, and ol.proj.Projection the image projection. The canvas returned by this function is cached by the source. The this keyword inside the function references the ol.source.ImageCanvas.

ol.Color{Array.<number>} experimental

A color represented as a short array [red, green, blue, alpha]. red, green, and blue should be integers in the range 0..255 inclusive. alpha should be a float in the range 0..1 inclusive.

ol.Coordinate{Array.<number>}

An array of numbers representing an xy coordinate. Example: [16, 48].

ol.CoordinateFormatType()

src/ol/coordinate.js, line 15

A function that takes a ol.Coordinate and transforms it into a {string}.

ol.Extent{Array.<number>}

An array of numbers representing an extent: [minx, miny, maxx, maxy].

ol.FeatureLoader() experimental

src/ol/featureloader.js, line 18

ol.FeatureStyleFunction()

src/ol/feature.js, line 290

A function that returns a style given a resolution. The this keyword inside the function references the ol.Feature to be styled.

ol.ImageLoadFunctionType() experimental

src/ol/imageloadfunction.js, line 21

A function that takes an ol.Image for the image and a {string} for the src as arguments. It is supposed to make it so the underlying image ol.Image#getImage is assigned the content specified by the src. If not specified, the default is

function(image, src) {
  image.getImage().src = src;
}

Providing a custom imageLoadFunction can be useful to load images with post requests or - in general - through XHR requests, where the src of the image element would be set to a data URI when the content is loaded.

ol.LoadingStrategy() experimental

src/ol/loadingstrategy.js, line 11

ol.OverlayPositioning{string}

Overlay position: 'bottom-left', 'bottom-center', 'bottom-right', 'center-left', 'center-center', 'center-right', 'top-left', 'top-center', 'top-right'

ol.Pixel{Array.<number>}

An array with two elements, representing a pixel. The first element is the x-coordinate, the second the y-coordinate of the pixel.

ol.PreRenderFunction() experimental

src/ol/framestate.js, line 21

Function to perform manipulations before rendering. This function is called with the ol.Map as first and an optional olx.FrameState as second argument. Return true to keep this function for the next frame, false to remove it.

ol.RendererType{string}

Available renderers: 'canvas', 'dom' or 'webgl'.

ol.Size{Array.<number>}

An array of numbers representing a size: [width, height].

ol.TileCoord{Array.<number>} experimental

An array of three numbers representing the location of a tile in a tile grid. The order is z, x, and y. z is the zoom level.

ol.TileLoadFunctionType() experimental

src/ol/tileloadfunction.js, line 11

A function that takes an ol.ImageTile for the image tile and a {string} for the src as arguments.

ol.TileUrlFunctionType() experimental

src/ol/tileurlfunction.js, line 43

A function that takes an ol.TileCoord for the tile coordinate, a {number} representing the pixel ratio and an ol.proj.Projection for the projection as arguments and returns a {string} or undefined representing the tile URL.

The ol.TileCoord's x value increases from left to right, y increases from bottom to top. At the bottom left corner, x and y are 0. To convert y to increase from top to bottom, use the following code:

var tileGrid = new ol.tilegrid.TileGrid({
  extent: extent,
  resolutions: resolutions,
  tileSize: tileSize
});

function calculateY(tileCoord) {
  var z = tileCoord[0];
  var yFromBottom = tileCoord[2];
  var resolution = tileGrid.getResolution(z);
  var tileHeight = ol.size.toSize(tileSize)[1];
  var matrixHeight =
      Math.floor(ol.extent.getHeight(extent) / tileHeight / resolution);
  return matrixHeight - yFromBottom - 1;
};

ol.TransformFunction()

src/ol/transformfunction.js, line 13

A transform function accepts an array of input coordinate values, an optional output array, and an optional dimension (default should be 2). The function transforms the input coordinate values, populates the output array, and returns the output array.