---
metadata:
  - name: generator
    content: Diplodoc Platform v5.64.2
alternate:
  - https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/util.hd.md
  - https://yandex.ru/dev/jsapi-v2-1/doc/ru/v2-1/ref/reference/util.hd.md
  - href: https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/util.hd.md
    type: text/markdown
    title: Markdown version
  - href: https://yandex.ru/dev/jsapi-v2-1/doc/en/llms.txt?revision=r21950234
    rel: describedby
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.ru/dev/jsapi-v2-1/doc/en/llms.txt?revision=r21950234

# util.hd

Static object.

Allows working with HD screens on various devices.

[Methods](#methods-summary)

## Methods {#methods-summary}

#|
|| **Name** | **Returns** | **Description** ||
|| [getPixelRatio](https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/util.hd.md#getPixelRatio)() | Number | Returns ratio of virtual and physical pixels on the screen. ||
|| [selectRatio](https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/util.hd.md#selectRatio)([hash](https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/util.hd.md#selectRatio-param-hash)) | Number | Returns result of selection — either the pixel ratio, or 1 if, for example, a string was passed. ||
|| [selectValue](https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/util.hd.md#selectValue)([hash](https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/util.hd.md#selectValue-param-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 {#method_detail}

### getPixelRatio {#getPixelRatio}

```javascript
{Number} getPixelRatio()
```

**Returns** ratio of virtual and physical pixels on the screen.

### selectRatio {#selectRatio}

```javascript
{Number} selectRatio(hash)
```

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

**Parameters:**

#|
|| **Parameter** | **Default value** | **Description**  ||
|| [`hash`](#selectRatio-param-hash)[*](*star) | — | Type: [IRatioMap](https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IRatioMap.md)

Object of type [IRatioMap](https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IRatioMap.md) for screens with different pixel ratios. ||
|#

\* Mandatory parameter/option.

### selectValue {#selectValue}

```javascript
{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:**

#|
|| **Parameter** | **Default value** | **Description**  ||
|| [`hash`](#selectValue-param-hash)[*](*star) | — | Type: Object\|[IRatioMap](https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IRatioMap.md)

Object of type [IRatioMap](https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IRatioMap.md) for screens with different pixel ratios. ||
|#

\* Mandatory parameter/option.

**Example:**

```javascript
// We need to add a picture to the balloon so it looks good on HD screens.
var balloonImages = {
   // Normal picture.
    "1": "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="" >'
    }
});
```

[*star]: Mandatory parameter/option.