Last active
May 28, 2019 19:55
-
-
Save reaferon/9bc05c7143f8fe30b6028bab681c2ee9 to your computer and use it in GitHub Desktop.
Yandex map with baloons #js #html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ymaps.ready(init); | |
| function init() { | |
| var myMap = new ymaps.Map("map", { | |
| center: [55.76, 37.64], | |
| zoom: 10 | |
| }), | |
| // Создаем геообъект с типом геометрии "Точка". | |
| myGeoObject = new ymaps.GeoObject({ | |
| // Описание геометрии. | |
| geometry: { | |
| type: "Point", | |
| coordinates: [55.8, 37.8] | |
| }, | |
| // Свойства. | |
| properties: { | |
| // Контент метки. | |
| iconContent: 'Метка', | |
| balloonContent: 'Меня можно перемещать' | |
| } | |
| }, { | |
| // Опции. | |
| // Иконка метки будет растягиваться под размер ее содержимого. | |
| preset: 'twirl#redStretchyIcon', | |
| // Метку можно перемещать. | |
| draggable: true | |
| }), | |
| // Создаем метку с помощью вспомогательного класса. | |
| myPlacemark1 = new ymaps.Placemark([55.8, 37.6], { | |
| // Свойства. | |
| // Содержимое иконки, балуна и хинта. | |
| iconContent: '1', | |
| balloonContent: 'Балун', | |
| hintContent: 'Стандартный значок метки' | |
| }, { | |
| // Опции. | |
| // Стандартная фиолетовая иконка. | |
| preset: 'twirl#violetIcon' | |
| }), | |
| myPlacemark2 = new ymaps.Placemark([55.76, 37.56], { | |
| // Свойства. | |
| hintContent: 'Собственный значок метки' | |
| }, { | |
| // Опции. | |
| // Своё изображение иконки метки. | |
| iconImageHref: '/maps/doc/jsapi/2.x/examples/images/myIcon.gif', | |
| // Размеры метки. | |
| iconImageSize: [30, 42], | |
| // Смещение левого верхнего угла иконки относительно | |
| // её "ножки" (точки привязки). | |
| iconImageOffset: [-3, -42] | |
| }); | |
| //myMap.controls.add('smallZoomControl'); | |
| // Добавляем все метки на карту. | |
| myMap.geoObjects.add(myPlacemark1) | |
| .add(myPlacemark2) | |
| .add(myGeoObject); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment