<?php
$lat = get_post_meta($post_id, 'map_lat', true);
$lng = get_post_meta($post_id, 'map_lng', true);
$zoom = get_post_meta($post_id, 'map_zoom', true);
$enable_street_views_google_map        = get_post_meta( $post_id, 'enable_street_views_google_map', true );
$marker_icon = st()->get_option('st_rental_icon_map_marker', '');
$map_iframe = get_post_meta($post_id,'map_iframe',true);
$address = get_post_meta($post_id, 'address', true);
$is_iframe = get_post_meta(get_the_ID(), 'is_iframe', true); ?>
<div class="st-map-wrapper">
    <div class="st-hr large"></div>
    <?php
    if (!$zoom) {
        $zoom = 13;
    }
    ?>
    <div class="st-flex space-between">
        <h2 class="st-heading-section"><?php echo __('Rental\'s Location', 'traveler') ?></h2>
        <?php if ($address) {
            ?>
            <div class="c-grey  d-flex align-items-center">
                <?php
                echo '<i class="stt-icon-location1"></i>';
                echo esc_html($address); ?></div>
            <?php
        } ?>
    </div>
    <?php
    $map_icon = st_get_map_marker_icon( 'st_rental', 'large' );
    $data_map = st_encode_single_item_map_data( $post_id, [ 'icon' => $map_icon ] );
    $google_api_key = st()->get_option( 'st_googlemap_enabled' );
    if ( $google_api_key === 'on' ) {
        ?>
        <div class="st-map">
            <div class="google-map gmap3" id="list_map"
                data-data_show='<?php echo str_ireplace( [ "'" ], '\"', $data_map ); ?>'
                data-lat="<?php echo esc_attr( trim( $lat ) ); ?>"
                data-lng="<?php echo esc_attr( trim( $lng ) ); ?>"
                data-icon="<?php echo esc_url( $map_icon ); ?>"
                data-street_views="<?php echo esc_attr( trim( $enable_street_views_google_map ) ); ?>"
                data-zoom="<?php echo (int) $zoom; ?>"
                data-disablecontrol="true"
                data-showcustomcontrol="true"
                data-style="normal">
            </div>
        </div>
        <?php
    } else {
        ?>
        <div class="st-map-box">
            <div class="google-map-mapbox"
                data-lat="<?php echo esc_attr( trim( $lat ) ); ?>"
                data-lng="<?php echo esc_attr( trim( $lng ) ); ?>"
                data-data_show='<?php echo str_ireplace( [ "'" ], '\"', $data_map ); ?>'
                data-icon="<?php echo esc_url( $map_icon ); ?>"
                data-zoom="<?php echo (int) $zoom; ?>"
                data-marker-size="large"
                data-disablecontrol="true"
                data-showcustomcontrol="true"
                data-style="normal">
                <div id="st-map"></div>
            </div>
        </div>
        <?php
    }
    ?>
</div>