
<div class="content text-center mt-4">
    <h4 class="title text-dark mb-5"><b> <?php echo e($title); ?> </b></h4>
    <form method="post" action="<?php echo e($action); ?>" onsubmit="formAction(this)">
        <?php if(isset($address)): ?>
            <?php echo method_field('PUT'); ?>
        <?php endif; ?>
        <?php echo csrf_field(); ?>
        <div class="row">

            <div class="col-lg-6">
                <div class="mb-4">
                    <label class="inputLabel"> <?php echo e(__('web.country_id')); ?>  </label>
                    <select name="country_id" onchange="fetchCities(this)" class="form-control form-select">
                        <option value=""><?php echo e(__('web.select')); ?></option>
                        <?php $__currentLoopData = $countries; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <option <?php echo e(isset($address) ?  ($address->country_id == $row->id ? 'selected': '') : ''); ?> value="<?php echo e($row->id); ?>"><?php echo e($row->title); ?></option>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </select>
                </div>
            </div>
            <div class="col-lg-6">
                <div class="mb-4">
                    <label class="inputLabel"> <?php echo e(__('web.city_id')); ?>  </label>
                    <select name="city_id" id="city_id" class="form-control form-select">
                        <option value=""><?php echo e(__('web.select')); ?></option>
                        <?php $__currentLoopData = $cities; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <option <?php echo e(isset($address) ?  ($address->city_id == $row->id ? 'selected': '') : ''); ?> value="<?php echo e($row->id); ?>"><?php echo e($row->title); ?></option>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </select>
                </div>
            </div>
            <div class="col-lg-12">
                <div class="mb-4">
                    <label class="inputLabel"><?php echo e(__('web.address_details')); ?></label>
                    <input type="text" name="address" value="<?php echo e($address->address ?? ''); ?>" class="form-control" placeholder="">
                </div>
            </div>
            <div class="col-lg-12">
                    <input type="hidden" name="latitude" id="latitude" value="<?php echo e($address->latitude ?? ''); ?>">
                    <input type="hidden" name="longitude" id="longitude" value="<?php echo e($address->longitude ?? ''); ?>">
                    <div id="map" style="width: 100%;height: 20pc"></div>
            </div>
        </div>

        <div class="d-flex justify-content-center align-items-center justify-content-center mt-5 ">
            <button type="button" class="butn btn-secondary  mx-1" data-bs-dismiss="modal"><?php echo e(__('web.close')); ?></button>
            <button type="submit" class="butn primary_butn mx-1"><?php echo e(__('web.send')); ?></button>
        </div>
    </form>
</div>



<script type="text/javascript">

    var latlng = new google.maps.LatLng(<?php echo isset($address) ? $address->latitude.', '.$address->longitude : '21.4989, 39.2509'; ?>);
    var map = new google.maps.Map(document.getElementById('map'), {
        center: latlng,
        zoom: 11,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    });
    var marker = new google.maps.Marker({
        position: latlng,
        map: map,
        title: 'Set lat/lon values for this property',
        draggable: true
    });
    google.maps.event.addListener(marker, 'dragend', function(a) {
        var div = document.createElement('div');
        document.getElementsByTagName('body')[0].appendChild(div);
        $("#latitude").val(function() {
            return  a.latLng.lat().toFixed(4);
        });
        $("#longitude").val(function() {
            return  a.latLng.lng().toFixed(4);
        });
    });

</script>
<?php /**PATH /Applications/MAMP/htdocs/electric/resources/views/web/pages/profile/addresses/form.blade.php ENDPATH**/ ?>