It is necessary that a certain layer or the entire site had a Yandex map in the background.
1 answer
Here is an example.
// ΠΠ°ΠΊ ΡΠΎΠ»ΡΠΊΠΎ Π±ΡΠ΄Π΅Ρ Π·Π°Π³ΡΡΠΆΠ΅Π½ API ΠΈ Π³ΠΎΡΠΎΠ² DOM, Π²ΡΠΏΠΎΠ»Π½ΡΠ΅ΠΌ ΠΈΠ½ΠΈΡΠΈΠ°Π»ΠΈΠ·Π°ΡΠΈΡ ymaps.ready(init); function init () { // Π‘ΠΎΠ·Π΄Π°Π½ΠΈΠ΅ ΡΠΊΠ·Π΅ΠΌΠΏΠ»ΡΡΠ° ΠΊΠ°ΡΡΡ ΠΈ Π΅Π³ΠΎ ΠΏΡΠΈΠ²ΡΠ·ΠΊΠ° ΠΊ ΠΊΠΎΠ½ΡΠ΅ΠΉΠ½Π΅ΡΡ Ρ // Π·Π°Π΄Π°Π½Π½ΡΠΌ id ("map") var myMap = new ymaps.Map('map', { // ΠΡΠΈ ΠΈΠ½ΠΈΡΠΈΠ°Π»ΠΈΠ·Π°ΡΠΈΠΈ ΠΊΠ°ΡΡΡ, ΠΎΠ±ΡΠ·Π°ΡΠ΅Π»ΡΠ½ΠΎ Π½ΡΠΆΠ½ΠΎ ΡΠΊΠ°Π·Π°ΡΡ // Π΅Π΅ ΡΠ΅Π½ΡΡ ΠΈ ΠΊΠΎΡΡΡΠΈΡΠΈΠ΅Π½Ρ ΠΌΠ°ΡΡΡΠ°Π±ΠΈΡΠΎΠ²Π°Π½ΠΈΡ center: [56.326944, 44.0075], // ΠΠΈΠΆΠ½ΠΈΠΉ ΠΠΎΠ²Π³ΠΎΡΠΎΠ΄ zoom: 13 }); }
*{ padding: 0; margin: 0; box-sizing: border-box; } html { height:100% } body { height: 100%; margin:0px; padding:0px } #map{ height:100%; width: 100%; position: absolute; top: 0; left: 0; } .content{ width: 300px; min-height: 200px; margin: 0 auto; background: #fff; position: relative; z-index: 1; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <script src="http://api-maps.yandex.ru/2.0/?load=package.full&lang=ru-RU" type="text/javascript"></script> <div class="content"> </div> <div id="map"> </div>
- Thanks, helped! I didnβt guess at the API documentation right away, but googling did nothing) I did it like in the example and everything works! - 888man
|