Answer the question
In order to leave comments, you need to log in
How to implement an adaptive api Yandex map on the site?
Hello.
I have a task to place the location of a place on the site using the Yandex Maps API. I did it, but on mobile devices it looks terrible, the map crawls out of the display. How can I make the map size adapt to mobile devices?
Answer the question
In order to leave comments, you need to log in
Use css
#map {
width: 640px; height: 600px;
}
@media (max-width: 320px) {
#map {
width: 260px; height: 300px;
}
}
var viewport = {
width : $(window).width(),
height : $(window).height()
};
var width = viewport.width;
var height = viewport.height;
if (width > 1000) {
var zoomval = 13;
} else {
var zoomval = 12;
}
function init() {
myMap = new ymaps.Map("map", {
center: [55.555555, 33.333333],
zoom: zoomval,
});
}
The author of the question did not find the answer? If you found it, could you share it?
I didn’t understand Yandex maps, I found a solution with google map
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question