Restrict map view area

Open on CodeSandbox

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
    <script src="https://js.api.mappable.world/v3/?apikey=<YOUR_APIKEY>&lang=en_US" type="text/javascript"></script>
    <script src="./common.js"></script>

    <script>
      window.map = null;
      main();
      async function main() {
        await mappable.ready;

        const {MMap, MMapDefaultSchemeLayer, MMapDefaultFeaturesLayer} = mappable;

        const {MMapDefaultMarker} = await mappable.import('@mappable-world/mappable-markers@0.0.1');

        map = new MMap(document.getElementById('app'), {
          location: LOCATION,
          restrictMapArea: RESTRICT_AREA,
          zoomRange: ZOOM_RANGE
        });

        map.addChild(new MMapDefaultFeaturesLayer());
        map.addChild(
          new MMapDefaultMarker({
            coordinates: RESTRICT_AREA[0],
            color: 'green'
          })
        );
        map.addChild(
          new MMapDefaultMarker({
            coordinates: RESTRICT_AREA[1],
            color: 'blue'
          })
        );
        map.addChild(new MMapDefaultSchemeLayer());
      }
    </script>

    <!-- prettier-ignore -->
    <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>
#app {
  width: 480px;
  height: 380px;
}
const LOCATION = {center: [48.11971, 29.43159], zoom: 12};
const ZOOM_RANGE = {min: 11, max: 13};

/**
 * Bounding box - bottom left and top right corners
 * @type {number[][]}
 */
const RESTRICT_AREA = [
  [47.33071, 29.33159],
  [48.64871, 29.54959]
];
<!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://unpkg.com/react@17/umd/react.production.min.js"></script>
    <script crossorigin src="https://unpkg.com/react-dom@17/umd/react-dom.production.min.js"></script>
    <script crossorigin src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>
    <script src="https://js.api.mappable.world/v3/?apikey=<YOUR_APIKEY>&lang=en_US" type="text/javascript"></script>
    <script src="./common.js"></script>

    <script type="text/babel">
      window.map = null;

      main();
      async function main() {
        const [mappableReact] = await Promise.all([
          mappable.import('@mappable-world/mappable-reactify'),
          mappable.ready
        ]);
        const reactify = mappableReact.reactify.bindTo(React, ReactDOM);
        const {MMap, MMapDefaultSchemeLayer, MMapDefaultFeaturesLayer} = reactify.module(mappable);
        const {MMapDefaultMarker} = reactify.module(await mappable.import('@mappable-world/mappable-markers@0.0.1'));

        function App() {
          return (
            <React.Fragment>
              <MMap location={LOCATION} restrictMapArea={RESTRICT_AREA} zoomRange={ZOOM_RANGE} ref={(x) => (map = x)}>
                <MMapDefaultSchemeLayer />
                <MMapDefaultFeaturesLayer />
                <MMapDefaultMarker coordinates={RESTRICT_AREA[0]} />
                <MMapDefaultMarker coordinates={RESTRICT_AREA[1]} />
              </MMap>
            </React.Fragment>
          );
        }

        ReactDOM.render(
          <React.StrictMode>
            <App />
          </React.StrictMode>,
          document.getElementById('app')
        );
      }
    </script>

    <!-- prettier-ignore -->
    <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://unpkg.com/vue@3/dist/vue.global.js"></script>
    <script src="https://js.api.mappable.world/v3/?apikey=<YOUR_APIKEY>&lang=en_US" type="text/javascript"></script>
    <script src="./common.js"></script>

    <script>
      window.map = null;

      main();
      async function main() {
        const [mappableVue] = await Promise.all([mappable.import('@mappable-world/mappable-vuefy'), mappable.ready]);
        const vuefy = mappableVue.vuefy.bindTo(Vue);
        const {MMap, MMapDefaultSchemeLayer, MMapDefaultFeaturesLayer} = vuefy.module(mappable);
        const {MMapDefaultMarker} = vuefy.module(await mappable.import('@mappable-world/mappable-markers@0.0.1'));

        const app = Vue.createApp({
          components: {MMap, MMapDefaultSchemeLayer, MMapDefaultFeaturesLayer, MMapDefaultMarker},
          setup() {
            const refMap = (ref) => {
              window.map = ref?.entity;
            };
            return {LOCATION, RESTRICT_AREA, ZOOM_RANGE, refMap};
          },
          template: `
                        <MMap :location="LOCATION" :restrictMapArea="RESTRICT_AREA" :zoomRange="ZOOM_RANGE" :ref="refMap">
                            <MMapDefaultSchemeLayer />
                            <MMapDefaultFeaturesLayer />
                            <MMapDefaultMarker :coordinates="RESTRICT_AREA[0]" />
                            <MMapDefaultMarker :coordinates="RESTRICT_AREA[1]" />
                        </MMap>`
        });
        app.mount('#app');
      }
    </script>

    <!-- prettier-ignore -->
    <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>