<?php

use yii\helpers\Html;
use yii\helpers\BaseHtml;
use yii\widgets\ActiveForm;
use frontend\assets\MapAsset;
MapAsset::register($this);
/* @var $this yii\web\View */
/* @var $model frontend\models\Place */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="col-md-6">

<div class="placegoogle-form">
  <p>Type in a place or business known to Google Places:</p>

    <?php 
$form = ActiveForm::begin();
?>
    <?php 
echo $form->errorSummary($model);
?>
 
    
    <?php 
echo $form->field($model, 'searchbox')->textInput(['maxlength' => 255])->label('Place');
?>
    
    <?php 
echo BaseHtml::activeHiddenInput($model, 'name');
?>
Beispiel #2
0
    public function run()
    {
        $widget = '';
        $widget .= Html::tag('div', '', ['id' => $this->mapDiv]);
        $options = ['map' => ['options' => $this->mapOptions], 'marker' => ['options' => $this->markersOptions, 'cluster' => $this->markersCluster]];
        $markers = $this->getMarkers();
        if (!empty($markers)) {
            $options['marker'] = ['values' => $markers];
        }
        if (!empty($this->events)) {
            $options['marker']['events'] = $this->events;
        }
        MapAsset::register($this->getVIew());
        $this->getView()->registerJs('mapDiv = $("#' . $this->mapDiv . '");');
        $this->getView()->registerJs('mapDiv.height(' . $this->height . ').gmap3(' . Json::encode($options) . ', "autofit");');
        $js = <<<'SCRIPT'
            map = mapDiv.gmap3("get");
            infobox = new InfoBox({
                pixelOffset: new google.maps.Size(-50, -65),
                closeBoxURL: '',
                enableEventPropagation: true
            });
            mapDiv.delegate('.infoBox .close','click',function () {
                infobox.close();
            });

            if (Modernizr.touch){
                map.setOptions({ draggable : false });
                var draggableClass = 'inactive';
                var draggableTitle = "Activate map";
                var draggableButton = $('<div class="draggable-toggle-button ' + draggableClass + '">' + draggableTitle + '</div>').appendTo(mapDiv);
                draggableButton.click(function () {
                    if($(this).hasClass('active')){
                        $(this).removeClass('active').addClass('inactive').text("Activate map");
                        map.setOptions({ draggable : false });
                    } else {
                        $(this).removeClass('inactive').addClass('active').text("Deactivate map");
                        map.setOptions({ draggable : true });
                    }
                });
            }
SCRIPT;
        $this->getView()->registerJs($js);
        $this->getView()->registerJs('$("#advance-search-slider").slider({
                range: "min",
                value: 500,
                min: 1,
                max: ' . $this->maximumRange . ',
                slide: function( event, ui ) {
                    $("#geo-radius").val(ui.value);
                    $("#geo-radius-search").val(ui.value);

                    $(".geo-location-switch").removeClass("off");
                    $(".geo-location-switch").addClass("on");
                    $("#geo-location").val("on");

                    mapDiv.gmap3({
                        getgeoloc:{
                            callback : function(latLng){
                                if (latLng){
                                    $("#geo-search-lat").val(latLng.lat());
                                    $("#geo-search-lng").val(latLng.lng());
                                }
                            }
                        }
                    });
                }
});');
        $this->getView()->registerJs('$("#geo-radius").val( jQuery("#advance-search-slider").slider("value"));
            $("#geo-radius-search" ).val($("#advance-search-slider").slider("value"));

            $(".geo-location-button .fa").click(function(){

            if($(".geo-location-switch").hasClass("off")){
                $(".geo-location-switch" ).removeClass("off");
                $(".geo-location-switch" ).addClass("on");
                $("#geo-location" ).val("on");

                mapDiv.gmap3({
                    getgeoloc:{
                        callback : function(latLng){
                            if (latLng){
                                $("#geo-search-lat").val(latLng.lat());
                                $("#geo-search-lng").val(latLng.lng());
                            }
                        }
                    }
                });
            } else {
                $(".geo-location-switch").removeClass("on");
                $(".geo-location-switch").addClass("off");
                $("#geo-location").val("off");
            }
        });');
        $widget .= '<div id="advanced-search-widget-version2">
        <div class="container">
            <div class="advanced-search-widget-content">
                <form action="/" method="get" id="views-exposed-form-search-view-other-ads-page" accept-charset="UTF-8">
                    <div id="edit-search-api-views-fulltext-wrapper" class="views-exposed-widget views-widget-filter-search_api_views_fulltext">
                        <div class="views-widget">
                            <div class="control-group form-type-textfield form-item-search-api-views-fulltext form-item">
                                <div class="controls">
                                    <input placeholder="' . \Yii::t('site', 'Ключевые слова...') . '" type="text" id="edit-search-api-views-fulltext" name="s" value="" size="30" maxlength="128" class="form-text">
                                </div>
                            </div>
                        </div>
                    </div>

                    <div id="edit-ad-location-wrapper" class="views-exposed-widget views-widget-filter-field_ad_location">
                        <div class="views-widget">
                            <div class="control-group form-type-select form-item-ad-location form-item">
                                <div class="controls">
                                    <select id="edit-ad-location" name="post_location" class="form-select" style="display: none;">
                                        <option value="All" selected="selected">' . \Yii::t('site', 'Местоположение...') . '</option>
                                        ' . implode('', []) . '
                                    </select>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div id="edit-field-category-wrapper" class="views-exposed-widget views-widget-filter-field_category">
                        <div class="views-widget">
                            <div class="control-group form-type-select form-item-field-category form-item">
                                <div class="controls">
                                    <select id="edit-field-category" name="category_name" class="form-select" style="display: none;">
                                        <option value="All" selected="selected">' . \Yii::t('site', 'Категория...') . '</option>
                                        ' . implode('', []) . '
                                    </select>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="advanced-search-slider">
                        <div class="geo-location-button">
                            <div class="geo-location-switch off"><i class="fa fa-location-arrow"></i></div>
                        </div>

                        <div id="advance-search-slider" class="value-slider ui-slider ui-slider-horizontal ui-widget ui-widget-content ui-corner-all" aria-disabled="false">
                            <a class="ui-slider-handle ui-state-default ui-corner-all" href="#">
								<span class="range-pin">
									<input type="text" name="geo-radius" id="geo-radius" value="100" data-default-value="100">
								</span>
                            </a>
                        </div>

                    </div>

                    <input type="text" name="geo-location" id="geo-location" value="off" data-default-value="off">
                    <input type="text" name="geo-radius-search" id="geo-radius-search" value="500" data-default-value="500">
                    <input type="text" name="geo-search-lat" id="geo-search-lat" value="0" data-default-value="0">
                    <input type="text" name="geo-search-lng" id="geo-search-lng" value="0" data-default-value="0">


                    <div class="views-exposed-widget views-submit-button">
                        <button class="btn btn-primary form-submit" id="edit-submit-search-view" name="" value="Search" type="submit">' . \Yii::t('site', 'Поиск') . '</button>
                    </div>
                </form>
            </div>
        </div>
    </div>';
        return Html::tag('section', $widget, ['id' => 'big-map']);
    }