Hello, there is a Yandex map code

ymaps.ready(init); var myMap, myPlacemark; function init() { myMap = new ymaps.Map("map", { center: [55.76, 37.64], }); myPlacemark = new ymaps.Placemark([51.841718, 55.1185161], { hintContent: "Москва!", balloonContent: "Π‘Π΅Π²Π΅Ρ€Π½ΠΎΠ΅ сияниС ΠžΡ„ΠΈΡ ΠΊΠΎΠΌΠΏΠ°Π½ΠΈΠΈ <br>Ρ‚Π΅Π». +7 (987) 850-77-33" }); myMap.geoObjects.add(myPlacemark); myPlacemark.balloon.open(); } 

How to add zoom function to adjust map size? thank

  • "adjust" - put the original scale of the map or add the ability on the client to zoom in and out? - Cheg
  • @Cheg Put the desired scale. Regards - Arcadiy

1 answer 1

You forgot to specify a zoom in the settings when initializing your card.

Working example:

 ymaps.ready(init); var myMap, myPlacemark; function init() { myMap = new ymaps.Map("map", { center: [51.841718, 55.1185161], zoom: 7 }); myPlacemark = new ymaps.Placemark([51.841718, 55.1185161], { hintContent: "Москва!", balloonContent: "Π‘Π΅Π²Π΅Ρ€Π½ΠΎΠ΅ сияниС ΠžΡ„ΠΈΡ ΠΊΠΎΠΌΠΏΠ°Π½ΠΈΠΈ <br>Ρ‚Π΅Π». +7 (987) 850-77-33" }); myMap.geoObjects.add(myPlacemark); myPlacemark.balloon.open(); } 
 html, body { padding: 0px; margin: 0px; height: 100%; } #map { position: absolute; width: 100%; height: 100%; } 
 <script src="https://api-maps.yandex.ru/2.1/?lang=ru_RU" type="text/javascript"></script> <div id="map"></div> 

  • Thanks, everything works - Arcadiy