_one_spot.php 2.6 KB
<?php
use yii\helpers\Html;
?>
<div class="kites-where-education-text-img">
    <div class="kites-where-education-title">
        <?=  Html::a("Cпот $model->name",['spots/view', 'translit' =>$model->translit ])  ?>
        <br>
        <?=  Html::a(" $model->address",['spots/view', 'translit' =>$model->translit ])  ?>
    </div>
    <div class="kites-master-wr-all">
        <div class="kites-master-wr">
            <div class="kites-master-left"><img src="/images/ico-kitler.jpg" width="24" height="23" alt=""><p>уровень сложности</p></div>
            <div class="kites-master-right">
                <img src="/images/<?= $model->difficulty_level?>.jpg" alt=""><p><?= $model->difficulty_level?></p>
            </div>
        </div>
    </div>
    <div class="kites-map-educ">
        <div id="google-map_<?=$model->id?>" style="width: 280px;height: 178px"></div>
    </div>
</div>
<script>
    function map_initialize_<?= $model['id'] ?>( map_element_id )
    {

        var image = '/images/icon_map.png';

        var myOptions_<?= $model['id'] ?> = {
            zoom: 10,
            center: new google.maps.LatLng(<?= $model->coordinates_x?>,<?= $model->coordinates_y?>),
            mapTypeId: google.maps.MapTypeId.ROADMAP,
            mapTypeControl: true,
            mapTypeControlOptions: {
                style: google.maps.MapTypeControlStyle.DROPDOWN_MENU
            },
            scrollwheel: false
        };


        var map_<?= $model['id'] ?> = new google.maps.Map(document.getElementById( map_element_id ),myOptions_<?= $model['id'] ?>);


        var mapLat_<?= $model['id'] ?> = <?= $model->coordinates_x?>;
        var mapLng_<?= $model['id']?> = <?= $model->coordinates_y?>;




        var latlng_<?= $model['id']?> = new google.maps.LatLng(mapLat_<?= $model['id']?>,mapLng_<?= $model['id']?>);


        var marker_<?= $model['id']?> = new google.maps.Marker({
            position: latlng_<?= $model['id']?>,
            map: map_<?= $model['id'] ?>,
            icon: image
        });


        var contentString_<?= $model['id']?> = '';




        var infowindow_<?= $model['id']?> = new google.maps.InfoWindow({
            content: contentString_<?= $model['id']?>
        });


        google.maps.event.addListener(marker_<?= $model['id']?>, 'click', function() {
            infowindow_<?= $model['id']?>.open(map_<?= $model['id'] ?>,marker_<?= $model['id']?>);
        });



    }

    $(function () {
        if( document.getElementById('google-map_<?=$model->id?>') )
        {
            map_initialize_<?= $model['id'] ?>( 'google-map_<?=$model->id?>' );
        }
    });



</script>