<?
$phone = get_field('site_phone', 'option');
$logodesc = get_field('site_logo_desc', 'option');
$menu = get_field('site_menu', 'option')['categories'];
$citys = get_field('map', 'option')['citys'];
$girlPhoto = get_field('girl_photo', 'option');
?>
<script type="text/javascript">
<? foreach($citys as $city) { ?>
window.<?= $city['alias']?>Map = false;
window.<?= $city['alias']?>MapInit = () => {
<?= $city['alias']?>Map = new ymaps.Map(
'yamap', {
center: <?= $city['coords']?>,
zoom: 12,
controls: ['zoomControl'] // 'zoomControl'
},
{
searchControlProvider: 'yandex#search'
}
);
<?= $city['alias']?>Map.geoObjects
<? foreach ($city['info'] as $info) {?>
.add(
new ymaps.Placemark(
<?= $info['coords']?>,
{
hintContent: 'Импульс',
balloonContent: '<?= $info['adress']?>'
},
{
iconLayout: 'default#image',
// iconImageHref: "<?//= $info['company_ico'] ? $info['company_ico'] : get_template_directory_uri().'/img/svg/loc.svg' ?>//",
// iconImageSize: [ <?//= $info['company_ico_w'] ?>//, <?//= $info['company_ico_h'] ?>// ]
}
)
)
<? } ?>
;
<?= $city['alias']?>Map.behaviors.disable('scrollZoom');
};
<? } ?>
</script>
<script type="text/javascript">
let citysInfo = {
<? foreach($citys as $city) { ?>
"<?= $city['alias']?>" : [
<? foreach($city['info'] as $info) {?>
{
adress: '<?= $info['adress']?>',
phone: '<?= $info['phone']?>',
email: '<?= $info['email']?>'
},
<? } ?>
],
<? } ?>
}
</script>
<script type="text/javascript">
let Cities = [<? foreach ($citys as $city) {?> "<?= $city['city']?>", <? } ?>];
</script>
<script id="map-info-template" type="text/x-handlebars-template">
{{#each adress}}
<article class="adress-info">
<p class="info-item">Адрес: <span class="adress">{{adress}}</span></p>
{{#if phone}}
<p class="info-item">Телефон: <a href="tel: {{phone}}" class="phone">{{phone}}</a></p>
{{/if}}
{{#if email}}
<p class="info-item">Email: <a href="mailto: {{email}}" class="email">{{email}}</a></p>
{{/if}}
</article>
{{/each}}
</script>
HTML
<div id="location">
<div class="map">
<div class="container">
<div class="location-menu">
<select name="city-select" class="city-select">
<?foreach ($citys as $city) {?>
<option value="<?= $city['city']?>" data-value="<?= $city['alias']?>"><?= $city['city']?></option>
<? } ?>
</select>
<div class="city-info"></div>
</div>
<div class="info">
<p class="mid-title">Хотите обсудить услугу лично?<br>Приезжайте к нам в офис!</p>
<p class="current-adress">г. Красноярск, ул. Партизана Железняка, 44Б</p>
</div>
</div>
<div id="yamap"></div>
</div>
</div>