<div id="location-picker-{{$id}}" class="form-field-location is-versionable {{ $blocksMode ? "blocks-mode--$blocksMode" : 'blocks-mode--hide' }} form-group{{ $parentHidden ? ' parent-hidden' : '' }}" style="{{ !empty($hidden) ? 'display:none' : '' }}">
    {!! Form::label($id, ucfirst($label), array('class' => 'control-label')) !!}
    <div class="well">
        @if($enabled)
            <div class="input-group location-picker-address-wrapper">
                {!! Form::text($name . '_address', '', array(
                    'id' => $id . '_address',
                    'class' => 'form-control',
                    'maxlength' => 150,
                    'disabled' => $enabled ? null : 'disabled',
                    'placeholder' => trans("backend.find_address")
                    )) !!}
                <span class="input-group-btn">
                    <button name="btn-search-address" class="btn btn-default" type="button">OK</button>
                </span>
            </div>
        @endif
        <div class="location-map"></div>
        <div class="row location-coordinates">
            <div class="col-sm-6">
                <div class="form-group @error($errorLatKey) has-error @enderror">
                    {!! Form::label($id . '_lat', trans("backend.latitude"), array('class' => 'control-label pull-left')) !!}
                    {!! Form::text($name . '[lat]', $value["lat"], array(
                        'id' => $id . '_lat',
                        'class' => 'form-control',
                        'maxlength' => 50,
                        'disabled' => $enabled ? null : 'disabled',
                        'data-toggle' => (isset($errors) && $errors->has($errorLatKey) ? 'tooltip': null),
                        'title' => (isset($errors) && $errors->has($errorLatKey) ? $errors->first($errorLatKey): null)
                        )) !!}
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group @error($errorLngKey) has-error @enderror">
                    {!! Form::label($id . '_lng', trans("backend.longitude"), array('class' => 'control-label pull-left')) !!}
                    {!! Form::text($name . '[lng]', $value["lng"], array(
                        'id' => $id . '_lng',
                        'class' => 'form-control',
                        'maxlength' => 50,
                        'disabled' => $enabled ? null : 'disabled',
                        'data-toggle' => (isset($errors) && $errors->has($errorLngKey) ? 'tooltip': null),
                        'title' => (isset($errors) && $errors->has($errorLngKey) ? $errors->first($errorLngKey): null)
                        )) !!}
                </div>
            </div>
        </div>
        {!! Form::hidden($name . '[zoom]', $value["zoom"], array('id' => $id . '_zoom')) !!}
    </div>
    @if(!empty($info))
        <span id="helpBlock" class="help-block">{{ $info }}</span>
    @endif
</div>

<script>
    $(function(){
        new Eae.View.BackendLocationPicker({
            el: $("#generic_form_{{RequestContext::get('generic_form_timestamp')}} #location-picker-{{$id}}"),
            fieldId: '{{ $id }}',
            required: @json($required),
            enabled: @json($enabled),
            parent:  {!! empty($parent) ? 'false': json_encode($parent) !!}
        });
    });
</script>
