<?php
$latAttributes = [
    'id' => $id . '_lat',
    'class' => 'form-control',
    'maxlength' => 50,
    'data-toggle' => (isset($errors) && $errors->has($errorLatKey) ? 'tooltip': null),
    'title' => (isset($errors) && $errors->has($errorLatKey) ? $errors->first($errorLatKey): null)
];
$lngAttributes = [
    'id' => $id . '_lng',
    'class' => 'form-control',
    'maxlength' => 50,
    'data-toggle' => (isset($errors) && $errors->has($errorLngKey) ? 'tooltip': null),
    'title' => (isset($errors) && $errors->has($errorLngKey) ? $errors->first($errorLngKey): null)
];
if (!$enabled) {
    $latAttributes['disabled'] = true;
    $lngAttributes['disabled'] = true;
}
?>
<div id="location-picker-<?php echo e($id); ?>" class="form-field-location is-versionable <?php echo e($blocksMode ? "blocks-mode--$blocksMode" : 'blocks-mode--hide'); ?> form-group<?php echo e($parentHidden ? ' parent-hidden' : ''); ?>" style="<?php echo e(!empty($hidden) ? 'display:none' : ''); ?>">
    <?php echo html()->label(ucfirst($label))->for($id)->attributes(['class' => 'control-label']); ?>

    <div class="well">
        <?php if($enabled): ?>
            <div class="input-group location-picker-address-wrapper">
                <?php echo e(html()->text($name . '_address', '')->attributes([
                    'id' => $id . '_address',
                    'class' => 'form-control',
                    'maxlength' => 150,
                    '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>
        <?php endif; ?>
        <div class="location-map"></div>
        <div class="row location-coordinates">
            <div class="col-sm-6">
                <div class="form-group <?php $__errorArgs = [$errorLatKey];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> has-error <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>">
                    <?php echo html()->label(trans("backend.latitude"))->for($id . '_lat')->attributes(['class' => 'control-label pull-left']); ?>

                    <?php echo e(html()->text($name . '[lat]', $value["lat"])->attributes($latAttributes)); ?>

                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group <?php $__errorArgs = [$errorLngKey];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> has-error <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>">
                    <?php echo html()->label(trans("backend.longitude"))->for($id . '_lng')->attributes(['class' => 'control-label pull-left']); ?>

                    <?php echo e(html()->text($name . '[lng]', $value["lng"])->attributes($lngAttributes)); ?>

                </div>
            </div>
        </div>
        <?php echo html()->hidden($name . '[zoom]')->value($value["zoom"])->attributes(['id' => $id . '_zoom']); ?>

    </div>
    <?php if(!empty($info)): ?>
        <span id="helpBlock" class="help-block"><?php echo e($info); ?></span>
    <?php endif; ?>
</div>

<script>
    $(function(){
        new Eae.View.BackendLocationPicker({
            el: $("#generic_form_<?php echo e(getRequestContext('generic_form_timestamp')); ?> #location-picker-<?php echo e($id); ?>"),
            fieldId: '<?php echo e($id); ?>',
            required: <?php echo json_encode($required, 15, 512) ?>,
            enabled: <?php echo json_encode($enabled, 15, 512) ?>,
            parent:  <?php echo empty($parent) ? 'false': json_encode($parent); ?>

        });
    });
</script>
<?php /**PATH /var/www/html/resources/views/admin/generic/components/forms/location.blade.php ENDPATH**/ ?>