Add YandexMap on the page.
Settings:
- x - longitude
- y - latitude
- height - height of map (Default: 400px)
Usage:
[yandex-map x="32.2" y="48.2" height="400"]
| function yandex_map($args){ | |
| $height = empty($args['height']) ? "400" : $args['height']; | |
| return " | |
| <div id='map' style='width: 100%; height: {$height}px'></div> | |
| <script src='//api-maps.yandex.ru/2.1/?lang=ru_RU' type='text/javascript'></script> | |
| <script> | |
| ymaps.ready(init); | |
| function init () { | |
| var myMap = new ymaps.Map('map', { | |
| center: [{$args['x']},{$args['y']}], | |
| zoom: 16, | |
| controls: ['zoomControl'] | |
| }), | |
| myPlacemark = new ymaps.Placemark([{$args['x']}, {$args['y']}]); | |
| myMap.geoObjects.add(myPlacemark); | |
| myMap.behaviors.disable('scrollZoom'); | |
| } | |
| </script>"; | |
| } | |
| add_shortcode('yandex-map','yandex_map'); |