Skip to content

Instantly share code, notes, and snippets.

@sukhikh18
Last active February 11, 2023 08:40
Show Gist options
  • Save sukhikh18/b9d6e0df22230f2dde4a6c2660d30866 to your computer and use it in GitHub Desktop.
Save sukhikh18/b9d6e0df22230f2dde4a6c2660d30866 to your computer and use it in GitHub Desktop.
Вызов Яндекс карты через API #Yandex #Map
<!DOCTYPE html>
<html>
<head>
<title>Пример API Яндекс карт</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!--
Укажите свой API-ключ. Тестовый ключ НЕ БУДЕТ работать на других сайтах.
Получить ключ можно в Кабинете разработчика: https://developer.tech.yandex.ru/keys/
-->
<script src="https://api-maps.yandex.ru/2.1/?lang=ru_RU&amp;apikey=<ваш API-ключ>" type="text/javascript"></script>
</head>
<body>
<div id="map1" style="height: 500px"></div>
<script>
// Поиск координат: https://yandex.ru/map-constructor/location-tool/
// API: https://yandex.ru/dev/maps/jsapi/doc/2.1/ref/reference/
ymaps.ready(function() {
const mapEl = document.querySelector("#map1");
// Init map
const map = new ymaps.Map(mapEl, {
center: [55.755814, 37.617635],
zoom: 10,
controls: ["fullscreenControl"]
});
// Disable "drag mouse for move position".
map.behaviors.disable(['drag', 'scrollZoom']);
// Add placemark to map
map.geoObjects.add(new ymaps.Placemark([55.755814, 37.617635], {
hintContent: 'Сообщение вызываемое при наведении на метку',
balloonContentHeader: 'Москва',
balloonContent: 'Текст всплывающей подсказки при клике',
balloonContentFooter: 'Подвал всплывающей подсказки'
}));
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment