<template>
    <div :class="(warningTitle && warningText) ?'location-main-container with-error' : 'location-main-container'">
        <div class="location-search-div" v-if="!(warningTitle && warningText)">
                <img src="./assets/search-1.svg" class="search-image"/>
                <gmap-autocomplete :componentRestrictions="{country:'in'}" :placeholder="'Search your location'" @place_changed="setPlace"></gmap-autocomplete>
                <div class='my-location-div' @click="gotoCurrentLocation">
                    <img src="./assets/ic-my-location.svg" />
                    <div>LOCATE ME</div>
                </div>
        </div>
        <div class="vue-google-maps-div" v-if="!(warningTitle && warningText)">
            <br>
            <gmap-map
            :center="center"
            :zoom="14"
            style=" height: 500px;"
            @click="updatePosDragEnd"
            >
            <gmap-marker
                :position="marker.position"
                @click="center=marker.position"
                :clickable="true"
                :draggable="true"
                @dragend="updatePosDragEnd"
            ></gmap-marker>
            </gmap-map>
            <div class="button-wrapper">
                <div :class="(confirmLocationEnabled)? 'button-div enabled' : 'button-div'" @click="confirmLocation">
                    CONFIRM LOCATION
                </div>
            </div>
        </div>
        <div class="location-error-overlay" v-if="warningTitle && warningText" @click="closeErrorPopup"></div>
        <div class="location-error-div" v-if="warningTitle && warningText">
            <img src="./assets/warning.jpg" />
            <div class="error-title">{{warningTitle}}</div>
            <div class="error-text">{{warningText}} <a style='font-weight: 700;' :href='enableLocationLink' v-if="warningTitle == 'Access Issue'">here</a></div>
        </div>
    </div>
</template>
<script>
    import LocationGoogleMap from './location-google-map';
    export default LocationGoogleMap;
</script>

