index.php 2.68 KB
<?php
use yii\helpers\Html;
use yii\bootstrap\ActiveForm;

/* @var $this yii\web\View */
/* @var $form yii\bootstrap\ActiveForm */
/* @var $model \frontend\models\SignupForm */
$this->registerCssFile('/css/school_one.css');
$this->registerJsFile('/js/jquery.scrollbox.min.js');
$this->title = 'Споты';
$this->params['breadcrumbs'][] = $this->title;
?>
    <div class="kites-where-education-wr my_margin">
        <div id="google-map" style="width: 920px; height: 380px; margin-left: 39px"></div>
        <script src="http://maps.google.com/maps/api/js?sensor=false"></script>
        <script>
            function map_initialize( map_element_id )
            {

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

                var myOptions = {
                    zoom: 5,
                    center: new google.maps.LatLng(46.656422, 33.487768),
                    mapTypeId: google.maps.MapTypeId.ROADMAP,
                    mapTypeControl: true,
                    mapTypeControlOptions: {
                        style: google.maps.MapTypeControlStyle.DROPDOWN_MENU
                    },
                    scrollwheel: false
                };


                var map = new google.maps.Map(document.getElementById( map_element_id ),myOptions);

                <?php foreach($dataProvider->getModels() as $data): ?>
                var mapLat_<?= $data['id'] ?> = <?= $data->coordinates_x?>;
                var mapLng_<?= $data['id']?> = <?= $data->coordinates_y?>;




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


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


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




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


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


            }

            window.onload = function()
            {
                if( document.getElementById('google-map') )
                {
                    map_initialize( 'google-map' );
                }
            };



        </script>
        <?php
        echo \yii\widgets\ListView::widget( [
            'dataProvider' => $dataProvider,
            'itemView'=>'_one_spot',
            'summary'=>'',
        ] );
        ?>
    </div>