T
T
TheRevan2018-08-29 14:51:38
css
TheRevan, 2018-08-29 14:51:38

How to fix the height of the Yandex map?

There is a Yandex map: 3af980dd30.jpg
There is a map initialization code:

$(document).ready(function(){
  if ($('.invoices-map').length) {
    ymaps.ready(initInvoicesMap);
  }
  console.log(ymaps);
})

function initInvoicesMap() {

  var multiRoute,
    mapText,
    mapLink;

  // Инициализация карту
  myInvoiceMap = new ymaps.Map($('.invoices-map')[0], {
    center: [55.752411, 37.623140],
    zoom: 9
  });
  console.log(myInvoiceMap);

}

There is a problem: When loading a page, if the Internet is very slow, then when updating the page (namely, when updating, when you load the page without a cache, everything is fine), the height of the map becomes 0 pixels and no requests are made to the server to draw map blocks:
4c7e689b96.jpg87879b55ee.jpg
Also, with any change in height screen (from full screen to normal, or resizing the content or browser) the map falls into place:
d31af04562.jpg
Also, when the map log is displayed on the console: 89f157cf26.jpg

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Egor Danchenko, 2018-08-29
@Danchenko

Only min-height will save here

L
lloydbanks, 2018-08-29
@lloydbanks

.invoices-mapmust have some height before the map loads. If you use 100% for absolute positioning, then the parent must have some height, otherwise it will be 0.
Try 100%using instead100vh

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question