PageSourceSearch

https://clever-toy.ru/res/widgets/locations-map/script.js?v=1645301614

js clever-toy.ru collected 2026-09-30 02:41:42 UTC 2,677 bytes, 85 lines download raw bytes

1/*
2 * @copyright 2019-2022 Dicr http://dicr.org
3 * @author Igor A Tarasov <[email protected]>
4 * @license proprietary
5 * @version 19.02.22 23:09:23
6 */
7
8"use strict";
9
10((window, $) => {
11
12    /**
13     * Виджет карты филиалов.
14     *
15     * @constructor
16     * @param {HTMLElement|jQuery<HTMLElement>} widget
17     * @param {Object} options
18     */
19    function LocationsMapWidget(widget, options)
20    {
21        let map;
22        const $widget = $(widget);
23
24        // var для IE
25        // noinspection JSUnresolvedFunction,JSUnresolvedVariable
26        const opts = window.ymaps.util.bounds.getCenterAndZoom(window.ymaps.util.bounds.fromPoints($.map(options.locations, loc => {
27            // noinspection JSUnresolvedVariable
28            return [loc.geo];
29        })), [$widget.width(), $widget.height()]);
30
31        if (opts.zoom > 16) {
32            opts.zoom = 16;
33        }
34
35        // noinspection JSUnusedGlobalSymbols
36        opts.controls = ["smallMapDefaultSet"];
37        opts.behaviors = ["drag", "dblClickZoom", "multiTouch", "rightMouseButtonMagnifier"];
38
39        // noinspection JSUnresolvedFunction,JSUnresolvedVariable
40        map = new window.ymaps.Map($widget[0], opts);
41
42        // noinspection JSUnresolvedVariable
43        $.each(options.locations, (i, loc) => {
44            // noinspection JSUnresolvedFunction,JSUnresolvedVariable
45            const mark = new window.ymaps.Placemark(loc.geo, {
46                hintContent: loc.name
47            });
48
49            // noinspection JSUnresolvedVariable
50            map.geoObjects.add(mark);
51        });
52
53        // noinspection JSUnresolvedVariable
54        window.ymaps.borders.load("RU", {quality: 0}).then(geojson => {
55            // noinspection JSUnresolvedFunction,JSUnresolvedVariable
56            const regions = window.ymaps.geoQuery(geojson);
57            // noinspection JSUnresolvedFunction
58            regions.addToMap(map);
59        });
60    }
61
62    // noinspection JSUnusedGlobalSymbols
63    /**
64     *  Плагин jQuery.
65     *
66     * @param {Object} options
67     * @returns {jQuery}
68     */
69    $.fn.locationsMap = function (options) {
70        const $widgets = $(this);
71
72        // отложенная инициализация до загрузки карт
73        // noinspection JSUnresolvedVariable
74        window.ymaps.ready(() => {
75            // noinspection JSUnresolvedVariable
76            if (options.locations && options.locations.length > 0) {
77                $widgets.each(function () {
78                    $(this).data('widget', new LocationsMapWidget(this, options));
79                });
80            }
81        });
82
83        return this;
84    };
85})(window, jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.