<?php

use Tangibledesign\Framework\Core\Settings\SettingKey;
use Tangibledesign\Framework\Widgets\General\MapWidget;

/* @var MapWidget $mhCurrentWidget */
global $mhCurrentWidget;
$mhMarkerType = $mhCurrentWidget->getMarkerType();
$mhMapProvider = tdf_settings()->getMapProvider();
$mhGoogleMapsApiKeyConfigured = tdf_app('maps_v2_runtime')->googleMapsApiKeyConfigured();
?>
<div class="myhome-app">
    <?php if ($mhMapProvider === SettingKey::MAP_PROVIDER_GOOGLE_MAPS && $mhGoogleMapsApiKeyConfigured) : ?>
        <mh-simple-google-map
                map-id="myhome-map-<?php echo esc_attr($mhCurrentWidget->get_id()); ?>"
                map-type="roadmap"
                :position="<?php echo htmlspecialchars(json_encode($mhCurrentWidget->getPosition())); ?>"
                :zoom="<?php echo esc_attr($mhCurrentWidget->getZoom()); ?>"
                marker-type="<?php echo esc_attr($mhMarkerType); ?>"
                marker-id="myhome-map-marker-<?php echo esc_attr($mhCurrentWidget->get_id()); ?>"
                icon="<?php echo esc_attr($mhCurrentWidget->getIcon()); ?>"
        >
            <div slot-scope="props">
                <div
                        id="myhome-map-<?php echo esc_attr($mhCurrentWidget->get_id()); ?>"
                        class="myhome-map"
                ></div>

                <div class="myhome-map-marker-hide">
                    <?php if ($mhMarkerType === 'big') : ?>


                    <?php elseif ($mhMarkerType === 'small') : ?>
                        <div
                                id="myhome-map-marker-<?php echo esc_attr($mhCurrentWidget->get_id()); ?>"
                                class="myhome-map-marker"
                        >
                            <div class="myhome-map-marker__small-circle"></div>
                        </div>
                    <?php endif; ?>
                </div>
            </div>
        </mh-simple-google-map>
    <?php endif; ?>

    <?php if ($mhMapProvider === SettingKey::MAP_PROVIDER_OPEN_STREET_MAP) : ?>
        <mh-simple-open-street-map
                map-id="myhome-listing__map-<?php echo esc_attr($mhCurrentWidget->get_id()); ?>"
                :zoom="<?php echo esc_attr($mhCurrentWidget->getZoom()); ?>"
                :position="<?php echo htmlspecialchars(json_encode($mhCurrentWidget->getPosition())); ?>"
                marker-type="<?php echo esc_attr($mhCurrentWidget->getMarkerType()); ?>"
                icon="<?php echo esc_attr($mhCurrentWidget->getIcon()); ?>"
        >
            <div slot-scope="props">
                <div
                        id="myhome-listing__map-<?php echo esc_attr($mhCurrentWidget->get_id()); ?>"
                        class="myhome-map"
                ></div>
            </div>
        </mh-simple-open-street-map>
    <?php endif; ?>
</div>
