E
E
EVOSandru62015-11-26 13:22:06
API
EVOSandru6, 2015-11-26 13:22:06

How to set fixed sizes in Yandex map or as a percentage?

Good afternoon,
The problem is this,
the Map goes beyond the area of ​​the parent block
<div id="map"></div>
. I tried to create a map in this way, but the dimensions do not change.

myMap = new ymaps.Map('map',
                {
                    center: [latitude, longitude],
                    zoom: 10,
                    size: (100, 100),
                },
                {
                    searchControlProvider: 'yandex#search#zoom'
                });

In firebug, inside my #map, this trouble comes up:
<ymaps class="ymaps-map ymaps-i-ua_js_yes" style="z-index: 0; width: 859px; height: 400px;"><ymaps class="ymaps-glass-pane ymaps-events-pane" unselectable="on" style="z-index: 500; position: absolute; width: 859px; height: 400px; left: 0px; top: 0px; -webkit-user-select: none; transform: translate3d(0px, 0px, 0px) scale(1, 1); cursor: url(https://api-maps.yandex.ru/2.0.42/images/ef50ac9e93aaebe3299791c79f277f8e.cur) 16 16, url(https://api-maps.yandex.ru/2.0.42/images/ef50ac9e93aaebe3299791c79f277f8e.cur), move;"></ymaps><ymaps class="ymaps-layers-pane" style="z-index: 100; position: absolute; left: 430px; top: 200px;"><ymaps style="z-index: 150; position: absolute; transform: translate3d(0px, 0px, 0px) scale(1, 1);"><canvas height="656" width="1115" style="position: absolute; width: 1115px; height: 656px; left: -557px; top: -328px;"></canvas></ymaps></ymaps><ymaps class="ymaps-copyrights-pane" style="z-index: 1000; position: absolute;"><ymaps><ymaps class="ymaps-copyrights-logo"><ymaps class="ymaps-logotype-div"><a target="_blank" class="ymaps-logo-link ymaps-logo-link-ru" href="https://maps.yandex.ru/?origin=jsapi&amp;ll=43.271758,76.938008&amp;z=10&amp;l="><ymaps class="ymaps-logo-link-wrap"></ymaps></a></ymaps></ymaps><ymaps class="ymaps-copyrights-legend"><ymaps class="ymaps-copyright-legend-container"><ymaps class="ymaps-copyright-legend"><ymaps class="ymaps-copyright-legend-element ymaps-copyright-legend-element-black"><ymaps style="display: inline;">© Яндекс</ymaps></ymaps></ymaps><ymaps class="ymaps-copyright-agreement ymaps-copyright-agreement-black"><a href="https://legal.yandex.ru/maps_termsofuse/?lang=ru" target="_blank">Условия использования</a></ymaps></ymaps></ymaps></ymaps></ymaps><ymaps class="ymaps-overlay-stepwise-pane" style="z-index: 600; position: absolute; left: 430px; top: 200px;"><ymaps class="ymaps-point-overlay" unselectable="on" style="position: absolute; height: 0px; width: 0px; -webkit-user-select: none; left: 0px; top: 0px; z-index: 650;"><ymaps><ymaps class="ymaps-image-with-content" style="position: absolute; left: -10px; top: -40px; width: 37px; height: 42px; background-image: url(https://api-maps.yandex.ru/2.0.42/images/2c3d90d4e522c1f62b6cf3e59f7a877d.png); background-size: 37px 42px; background-position: 0px 0px;"><ymaps class="ymaps-image-with-content-content" style="font: 13px Arial,sans-serif;position: absolute;text-align: center;left: 6px;top: 6px;width: 16px;height: 16px;"><ymaps id="id_144853275118487552_0"><ymaps></ymaps></ymaps></ymaps></ymaps></ymaps></ymaps></ymaps></ymaps>

How to set the dimensions fixed or in percentage for the map?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Pavlov, 2015-11-26
@EVOSandru6

They say "you need to specify the container for the map using the id option, and already set the size of the container as a percentage."

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question