Documentation
Reference
2.1.50 (current version)
collection
interactivityModel
Interfaces
2.1.51 (release candidate)
collection
interactivityModel
Interfaces

util.hd

Static object.

Allows working with HD screens on various devices.

Methods

util.hd()

Methods

NameReturnsDescription
getPixelRatio()

Number

Returns ratio of virtual and physical pixels on the screen.

selectRatio(hash)

Number

Returns result of selection — either the pixel ratio, or 1 if, for example, a string was passed.

selectValue(hash)

Object

Returns an object from the passed hash that is equal to or closest to the pixel ratio key. If something other than a hash was passed, such as a string or function, then it is returned.

Methods details

getPixelRatio

{Number} getPixelRatio()

Returns ratio of virtual and physical pixels on the screen.

selectRatio

{Number} selectRatio(hash)

Returns result of selection — either the pixel ratio, or 1 if, for example, a string was passed.

Parameters:

ParameterDefault valueDescription
hash*
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

Type: IRatioMap

Object of type IRatioMap for screens with different pixel ratios.

* Mandatory parameter/option.

selectValue

{Object} selectValue(hash)

Returns an object from the passed hash that is equal to or closest to the pixel ratio key. If something other than a hash was passed, such as a string or function, then it is returned.

Parameters:

ParameterDefault valueDescription
hash*
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

Type: Object|IRatioMap

Object of type IRatioMap for screens with different pixel ratios.

* Mandatory parameter/option.

Example:

// We need to add a picture to the balloon so it looks good on HD screens.
var balloonImages = {
   // Normal picture.
    "100x100.png",
   // Picture for Retina.
    "2": "200x200.png"
},
 var img = ymaps.util.hd.selectValue(balloonImages);
// Adding the point to the map.
myMap.geoObjects.add(new ymaps.GeoObject({
    geometry: "Point",
    coordinates: [55, 37],
    properties: {
        balloonContent:
            '<img src="' + img + '" width="100" alt="" >'
}, {});