ym.modules.provider.Icon

Overview

Represents a symbol as a marker on the map.

var myIcon = ym.icon({
    iconUrl: 'my-icon.png',
    iconRetinaUrl: 'my-icon@2x.png',
    iconSize: [38, 95],
    iconAnchor: [22, 94],
    popupAnchor: [-3, -76],
    shadowUrl: 'my-icon-shadow.png',
    shadowRetinaUrl: 'my-icon-shadow@2x.png',
    shadowSize: [68, 95],
    shadowAnchor: [22, 94]
});

ym.marker([50.505, 30.57], {icon: myIcon}).addTo(map);  

Initialization

Factory: ym.icon(options)

Creates an icon instance with the specified options.

Parameter: options

Option properties Description Data type
iconUrl The URL that corresponds to the icon (absolute or relative to your script path)
[required]
string
iconRetinaUrl Used for retina display devices. The URL corresponding to the retina-sized version of the symbol (absolute or relative to your script path). string
iconSize The size of the icon in pixels. Point
iconAnchor The coordinates of the top of the symbol (relative to its upper left corner). The symbol is aligned so that this point is located at the geographical position of the marker. Centered by default if the size is specified (can also be set in CSS with negative borders). Point
shadowUrl The URL that matches the icon's shadow image. If not specified, no shadow image is created. string
shadowRetinaUrl Used for retina display devices. The URL corresponding to the retina-sized version of the symbol's shadow image. If not specified, no shadow image is created. string
shadowSize The size of the symbol's shadow image in pixels. Point
shadowAnchor The coordinates of the tip of the symbol's shadow image (relative to its upper left corner). Same as iconAnchor, if not specified. Point
popupAnchor The coordinates of the point from which popups appear, relative to the anchor of the icon. Point
className The coordinates of the point from which popups appear, relative to the anchor of the icon. string