# OpenLayers.Icon

The icon represents a graphical icon on the screen. Typically used in conjunction with a OpenLayers.Marker to represent markers on a screen.

An icon has a url, size and position. It also contains an offset which allows the center point to be represented correctly. This can be provided either as a fixed offset or a function provided to calculate the desired offset.

Summary

OpenLayers.Icon | The icon represents a graphical icon on the screen.
Properties |
url | {String} image url
size | {<OpenLayers.Size>|Object} An OpenLayers.Size or an object with a ‘w’ and ‘h’ properties.
offset | {<OpenLayers.Pixel>|Object} distance in pixels to offset the image when being rendered.
calculateOffset | {Function} Function to calculate the offset (based on the size)
imageDiv | {DOMElement}
px | {<OpenLayers.Pixel>|Object} An OpenLayers.Pixel or an object with a ‘x’ and ‘y’ properties.
Constructor |
OpenLayers.Icon | Creates an icon, which is an image tag in a div.
Functions |
destroy | Nullify references and remove event listeners to prevent circular references and memory leaks
clone | {OpenLayers.Icon} A fresh copy of the icon.
setSize |
setUrl |
draw | Move the div to the given pixel.
erase | Erase the underlying image element.
setOpacity | Change the icon’s opacity
moveTo | move icon to passed in px.
display | Hide or show the icon
isDrawn | {Boolean} Whether or not the icon is drawn.

### Properties

### url

{String} image url

### size

{<OpenLayers.Size>|Object} An OpenLayers.Size or an object with a ‘w’ and ‘h’ properties.

### offset

{<OpenLayers.Pixel>|Object} distance in pixels to offset the image when being rendered. An OpenLayers.Pixel or an object with a ‘x’ and ‘y’ properties.

### calculateOffset

{Function} Function to calculate the offset (based on the size)

### imageDiv

{DOMElement}

### px

{<OpenLayers.Pixel>|Object} An OpenLayers.Pixel or an object with a ‘x’ and ‘y’ properties.

### Constructor

### OpenLayers.Icon

Creates an icon, which is an image tag in a div.

url | {String}
size | {<OpenLayers.Size>|Object} An OpenLayers.Size or an object with a ‘w’ and ‘h’ properties.
offset | {<OpenLayers.Pixel>|Object} An OpenLayers.Pixel or an object with a ‘x’ and ‘y’ properties.
calculateOffset | {Function}

### Functions

### destroy

> destroy: function()

Nullify references and remove event listeners to prevent circular references and memory leaks

### clone

> clone: function()

#### Returns

{OpenLayers.Icon} A fresh copy of the icon.

### setSize

> setSize: function( | size | )

#### Parameters

size | {<OpenLayers.Size>|Object} An OpenLayers.Size or an object with a ‘w’ and ‘h’ properties.

### setUrl

> setUrl: function( | url | )

#### Parameters

url | {String}

### draw

> draw: function( | px | )

Move the div to the given pixel.

#### Parameters

px | {<OpenLayers.Pixel>|Object} An OpenLayers.Pixel or an object with a ‘x’ and ‘y’ properties.

#### Returns

{DOMElement} A new DOM Image of this icon set at the location passed-in

### erase

> erase: function()

Erase the underlying image element.

### setOpacity

> setOpacity: function( | opacity | )

Change the icon’s opacity

#### Parameters

opacity | {float}

### moveTo

> moveTo: function ( | px | )

move icon to passed in px.

#### Parameters

px | {<OpenLayers.Pixel>|Object} the pixel position to move to. An OpenLayers.Pixel or an object with a ‘x’ and ‘y’ properties.

### display

> display: function( | display | )

Hide or show the icon

#### Parameters

display | {Boolean}

### isDrawn

> isDrawn: function()

#### Returns

{Boolean} Whether or not the icon is drawn.

> destroy: function()

Nullify references and remove event listeners to prevent circular references and memory leaks

> clone: function()

{OpenLayers.Icon} A fresh copy of the icon.
Creates an icon, which is an image tag in a div.

> setSize: function( | size | )

> setUrl: function( | url | )

> draw: function( | px | )

Move the div to the given pixel.

> erase: function()

Erase the underlying image element.

> setOpacity: function( | opacity | )

Change the icon’s opacity

> moveTo: function ( | px | )

move icon to passed in px.

> display: function( | display | )

Hide or show the icon

> isDrawn: function()

{Boolean} Whether or not the icon is drawn.
Instances of OpenLayers.Marker are a combination of a OpenLayers.LonLat and an OpenLayers.Icon.
Close