Создание наложения изображения на карту

Изображение взято из исследования Яндекса Улицы России

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
        <script crossorigin src="https://cdn.jsdelivr.net/npm/@babel/standalone@7/babel.min.js"></script>

        <!-- To make the map appear, you must add your apikey -->
        <script src="https://api-maps.yandex.ru/v3/?apikey=<YOUR_APIKEY>&lang=en_US" type="text/javascript"></script>

        <script
            data-plugins="transform-modules-umd"
            data-presets="react, typescript"
            type="text/babel"
            src="../variables.ts"
        ></script>
        <script
            data-plugins="transform-modules-umd"
            data-presets="typescript"
            type="text/babel"
            src="./common.ts"
        ></script>
        <script data-plugins="transform-modules-umd" data-presets="typescript" type="text/babel">
            import {LOCATION, IMAGE_BOUNDS, IMAGE_PATH, IMAGE_OVERLAY_CLASSNAME, ZOOM_RANGE} from '../variables';
            window.map = null;
            
            main();
            async function main() {
                // Waiting for all api elements to be loaded
                await ymaps3.ready;
                const {YMap, YMapDefaultSchemeLayer, YMapDefaultFeaturesLayer} = ymaps3;
            
                const {YMapImageOverlay} = await ymaps3.import('@yandex/ymaps3-default-ui-theme');
            
                // Initialize the map
                map = new YMap(
                    // Pass the link to the HTMLElement of the container
                    document.getElementById('app'),
                    // Pass the map initialization parameters
                    {
                        location: LOCATION,
                        showScaleInCopyrights: true,
                        zoomRange: ZOOM_RANGE
                    },
                    [
                        // Add a map scheme layer
                        new YMapDefaultSchemeLayer({}),
                        // Add a layer of geo objects to display the polygons
                        new YMapDefaultFeaturesLayer({})
                    ]
                );
            
                const imageOverlay = new YMapImageOverlay({
                    bounds: IMAGE_BOUNDS,
                    imageUrl: IMAGE_PATH,
                    className: IMAGE_OVERLAY_CLASSNAME
                });
            
                map.addChild(imageOverlay);
            }
        </script>

        <style> html, body, #app { width: 100%; height: 100%; margin: 0; padding: 0; font-family: Arial, Helvetica, sans-serif; } .toolbar { position: absolute; z-index: 1000; top: 0; left: 0; display: flex; align-items: center; padding: 16px; } .toolbar a { padding: 16px; }  </style>
        <link rel="stylesheet" href="./common.css" />
    </head>
    <body>
        <div id="app"></div>
    </body>
</html>
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
        <script crossorigin src="https://cdn.jsdelivr.net/npm/react@17/umd/react.production.min.js"></script>
        <script crossorigin src="https://cdn.jsdelivr.net/npm/react-dom@17/umd/react-dom.production.min.js"></script>
        <script crossorigin src="https://cdn.jsdelivr.net/npm/@babel/standalone@7/babel.min.js"></script>
        <!-- To make the map appear, you must add your apikey -->
        <script src="https://api-maps.yandex.ru/v3/?apikey=<YOUR_APIKEY>&lang=en_US" type="text/javascript"></script>

        <script
            data-plugins="transform-modules-umd"
            data-presets="typescript"
            type="text/babel"
            src="../variables.ts"
        ></script>
        <script
            data-plugins="transform-modules-umd"
            data-presets="typescript"
            type="text/babel"
            src="./common.ts"
        ></script>
        <script data-plugins="transform-modules-umd" data-presets="react, typescript" type="text/babel">
            import {LOCATION, IMAGE_BOUNDS, IMAGE_PATH, IMAGE_OVERLAY_CLASSNAME, ZOOM_RANGE} from '../variables';
            
            window.map = null;
            
            main();
            async function main() {
                // For each object in the JS API, there is a React counterpart
                // To use the React version of the API, include the module @yandex/ymaps3-reactify
                const [ymaps3React] = await Promise.all([ymaps3.import('@yandex/ymaps3-reactify'), ymaps3.ready]);
                const reactify = ymaps3React.reactify.bindTo(React, ReactDOM);
                const {YMap, YMapDefaultSchemeLayer, YMapDefaultFeaturesLayer} = reactify.module(ymaps3);
            
                const {YMapImageOverlay} = reactify.module(await ymaps3.import('@yandex/ymaps3-default-ui-theme'));
            
                function App() {
                    return (
                        // Initialize the map and pass initialization parameters
                        <YMap location={LOCATION} showScaleInCopyrights={true} zoomRange={ZOOM_RANGE} ref={(x) => (map = x)}>
                            {/* Add a map scheme layer */}
                            <YMapDefaultSchemeLayer />
                            {/* Add a layer of geo objects to display the rectangle */}
                            <YMapDefaultFeaturesLayer />
                            <YMapImageOverlay bounds={IMAGE_BOUNDS} imageUrl={IMAGE_PATH} className={IMAGE_OVERLAY_CLASSNAME} />
                        </YMap>
                    );
                }
            
                ReactDOM.render(
                    <React.StrictMode>
                        <App />
                    </React.StrictMode>,
                    document.getElementById('app')
                );
            }
        </script>

        <style> html, body, #app { width: 100%; height: 100%; margin: 0; padding: 0; font-family: Arial, Helvetica, sans-serif; } .toolbar { position: absolute; z-index: 1000; top: 0; left: 0; display: flex; align-items: center; padding: 16px; } .toolbar a { padding: 16px; }  </style>
        <link rel="stylesheet" href="./common.css" />
    </head>
    <body>
        <div id="app"></div>
    </body>
</html>
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
        <script crossorigin src="https://cdn.jsdelivr.net/npm/vue@3/dist/vue.global.js"></script>
        <script crossorigin src="https://cdn.jsdelivr.net/npm/@babel/standalone@7/babel.min.js"></script>

        <script src="https://api-maps.yandex.ru/v3/?apikey=<YOUR_APIKEY>&lang=en_US" type="text/javascript"></script>

        <script
            data-plugins="transform-modules-umd"
            data-presets="react, typescript"
            type="text/babel"
            src="../variables.ts"
        ></script>
        <script
            data-plugins="transform-modules-umd"
            data-presets="typescript"
            type="text/babel"
            src="./common.ts"
        ></script>
        <script data-plugins="transform-modules-umd" data-presets="typescript" type="text/babel">
            import {LOCATION, IMAGE_BOUNDS, IMAGE_PATH, IMAGE_OVERLAY_CLASSNAME, ZOOM_RANGE} from '../variables';
            
            window.map = null;
            
            async function main() {
                // For each object in the JS API, there is a Vue counterpart
                // To use the Vue version of the API, include the module @yandex/ymaps3-vuefy
                const [ymaps3Vue] = await Promise.all([ymaps3.import('@yandex/ymaps3-vuefy'), ymaps3.ready]);
                const vuefy = ymaps3Vue.vuefy.bindTo(Vue);
                const {YMap, YMapDefaultSchemeLayer, YMapDefaultFeaturesLayer} = vuefy.module(ymaps3);
            
                const {YMapImageOverlay} = vuefy.module(await ymaps3.import('@yandex/ymaps3-default-ui-theme'));
            
                const app = Vue.createApp({
                    components: {
                        YMap,
                        YMapDefaultSchemeLayer,
                        YMapDefaultFeaturesLayer,
                        YMapImageOverlay
                    },
                    setup() {
                        const refMap = (ref) => {
                            window.map = ref?.entity;
                        };
                        return {
                            LOCATION,
                            IMAGE_BOUNDS,
                            IMAGE_PATH,
                            IMAGE_OVERLAY_CLASSNAME,
                            ZOOM_RANGE,
                            refMap
                        };
                    },
                    template: `
                      <!--Initialize the map and pass initialization parameters-->
                      <YMap :location="LOCATION" :showScaleInCopyrights="true" :zoomRange="ZOOM_RANGE" :ref="refMap">
                        <!--Add a map scheme layer-->
                        <YMapDefaultSchemeLayer/>
                        <!-- Add a layer of geo objects to display the rectangle -->
                        <YMapDefaultFeaturesLayer/>
            
                        <YMapImageOverlay :bounds="IMAGE_BOUNDS" :imageUrl="IMAGE_PATH" :className="IMAGE_OVERLAY_CLASSNAME" />
                      </YMap>`
                });
                app.mount('#app');
            }
            main();
        </script>

        <style> html, body, #app { width: 100%; height: 100%; margin: 0; padding: 0; font-family: Arial, Helvetica, sans-serif; } .toolbar { position: absolute; z-index: 1000; top: 0; left: 0; display: flex; align-items: center; padding: 16px; } .toolbar a { padding: 16px; }  </style>
        <link rel="stylesheet" href="./common.css" />
    </head>
    <body>
        <div id="app"></div>
    </body>
</html>
import type {YMapLocationRequest, LngLatBounds, ZoomRange} from '@yandex/ymaps3-types';

export const LOCATION: YMapLocationRequest = {
    center: [49.1, 55.77], // starting position [lng, lat]
    zoom: 10 // starting zoom
};

export const ZOOM_RANGE: ZoomRange = {
    min: 9,
    max: 12
};

export const IMAGE_BOUNDS: LngLatBounds = [
    [48.97, 55.6],
    [49.23, 55.94]
];

export const IMAGE_PATH: string =
    'https://cloudcdn-ams-07.cdn.yandex.net/download.yandex.ru/company/figures/2017/streets/big_cities/i/63B64EA97E24E28C.png';

export const IMAGE_OVERLAY_CLASSNAME: string = 'image-overlay';
ymaps3.import.registerCdn('https://cdn.jsdelivr.net/npm/{package}', ['@yandex/ymaps3-default-ui-theme@0.0']);
.image-overlay {
    opacity: 0.8;
}