M
M
mipfikus2021-02-11 15:36:43
JavaScript
mipfikus, 2021-02-11 15:36:43

How to stretch a Yandex map by 100%?

The code:

<script src="http://api-maps.yandex.ru/2.0-stable/?load=package.standard&lang=ru-RU" type="text/javascript"></script>
<div id="map" style="width: 100%; height: 100%"></div>
<script type="text/javascript">
    ymaps.ready(init);
    var myMap;
    function init(){     
        myMap = new ymaps.Map ("map", {
            center: [55.76, 37.64],
            zoom: 10,
        });
        myMap.behaviors.enable('scrollZoom')
         myPlacemark = new ymaps.Placemark([55.70, 37.60], {
            });
            myMap.geoObjects.add(myPlacemark);
    }
</script>


If the "map" div is set to a height in percent, the map disappears; if in pixels, it appears.
I need to stretch the map to the full height of the block, how can I do this?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Artem Zolin, 2021-02-11
@mipfikus

Add height to parent or putheight: 100vh

F
freeExec, 2021-02-11
@freeExec

Variant with

<div id="map" style="width: 100%; height: 100%"></div>
worker, you have a jamb in something else.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question