Change the size of the map

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, MMapControls} = mappable;

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

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

        map.addChild((scheme = new MMapDefaultSchemeLayer()));
        map.addChild(new MMapControls({position: 'right'}).addChild(new MMapZoomControl({})));
      }

      mappable.ready.then(() => {
        let big = false;
        const container = document.getElementById('app');
        document.getElementById('manageMap').onclick = () => {
          big = !big;
          /**
           * Unlike previous versions of the API, the map instance is independent
           * without any options, monitors the size of the container using ResizeObserver
           */
          container.classList.toggle('smallMap', !big);
        };
      });
    </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 class="toolbar">
      <button type="button" id="manageMap">Expand/Collapse</button>
    </div>
    <div class="bigMap smallMap" id="app"></div>
  </body>
</html>
.bigMap {
  width: 430px !important;
  height: 320px !important;

  border: 1px solid #000;
}

.smallMap {
  width: 300px !important;
  height: 200px !important;
}
const LOCATION = {center: [55.44279, 25.24613], zoom: 9};
<!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, MMapControls, MMapListener} = reactify.module(mappable);

        const {MMapZoomControl} = reactify.module(await mappable.import('@mappable-world/mappable-controls@0.0.1'));

        function App() {
          const [big, toggleBig] = React.useState(false);
          const [location, setLocation] = React.useState(LOCATION);

          const onUpdate = React.useCallback(({location, mapInAction}) => {
            // Animation not happening
            if (!mapInAction) {
              setLocation({
                center: location.center,
                zoom: location.zoom
              });
            }
          }, []);

          return (
            <div className={'bigMap ' + (!big ? 'smallMap' : '')}>
              <div className="toolbar">
                <button type="button" onClick={() => toggleBig(!big)}>
                  Expand/Collapse
                </button>
              </div>
              <MMap location={location} ref={(x) => (map = x)}>
                <MMapListener onUpdate={onUpdate} />
                <MMapDefaultSchemeLayer />
                <MMapControls position="right">
                  <MMapZoomControl />
                </MMapControls>
              </MMap>
            </div>
          );
        }

        ReactDOM.render(
          <React.StrictMode>
            <App />
          </React.StrictMode>,
          document.getElementById('react-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="react-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, MMapControls, MMapListener} = vuefy.module(mappable);
        const {MMapZoomControl} = vuefy.module(await mappable.import('@mappable-world/mappable-controls@0.0.1'));

        const app = Vue.createApp({
          components: {MMap, MMapDefaultSchemeLayer, MMapControls, MMapListener, MMapZoomControl},
          setup() {
            const big = Vue.ref(false);
            const mapLocation = Vue.ref(LOCATION);
            const onUpdate = ({location, mapInAction}) => {
              if (!mapInAction) {
                mapLocation.value = {center: location.center, zoom: location.zoom};
              }
            };
            const refMap = (ref) => {
              window.map = ref?.entity;
            };
            return {mapLocation, refMap, onUpdate, big};
          },
          template: `
                        <div :class="{bigMap: true, smallMap: !big}">
                            <div className="toolbar">
                                <button type="button" @click="big = !big">Expand/Collapse</button>
                            </div>
                            <MMap :location="mapLocation" :ref="refMap">
                                <MMapListener :onUpdate="onUpdate" />
                                <MMapDefaultSchemeLayer />
                                <MMapControls position="right">
                                    <MMapZoomControl></MMapZoomControl>
                                </MMapControls>
                            </MMap>
                        </div>`
        });
        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>