// SPA init vue app
/*
Vue.config.errorHandler = function (err, vm, info) {
    console.log('[Global Error Handler]: Error in ' + info + ': ' + err);
};

Vue.config.warnHandler = function (err, vm, info) {
    //console.log('[Global Warning Handler]: Warning in ' + info + ': ' + err);
};
*/

Vue.config.debug = true;

Vue.prototype.global = window.global;
Vue.prototype.closePlayer = window.closePlayer;
Vue.prototype.ResizeRoutingDIvWidth = window.ResizeRoutingDIvWidth;
Vue.prototype.setBaseMap = window.setBaseMap;
Vue.prototype.setTimeout = window.setTimeout;

Vue.prototype.localStorage = window.localStorage;




var lastRequest = null;
var lastRequestIsSearch = false;


var vm = new Vue({
    el: '#app',
    data: function () {
        return {
            compassAvailable: false,
            makaniLoading: false,
            tour_options: {
                useKeyboardNavigation: true,
                labels: {
                    buttonSkip: 'Skip',
                    buttonPrevious: 'Previous',
                    buttonNext: 'Next',
                    buttonStop: 'Finish'
                },
                highlight: false,
                params: {
                    enableScrolling: false
                }
            },
            tour_main_callbacks: {
                onFinish: function () {
                    localStorage.setItem("tour_main_done", true);
                    if (vm.IsQuickSearchDetailDivVisible)
                        vm.infoTourDeffered.resolve();
                },
                onSkip: function () {
                    localStorage.setItem("tour_main_done", true);
                    if (vm.IsQuickSearchDetailDivVisible)
                        vm.infoTourDeffered.resolve();
                }
            },
            tour_main_steps: [
                {
                    target: '#tour_menu',
                    header: {
                        title: 'Main Menu',
                    },
                    content: `<ul><li>Information</li>
                                 <li>Favorite</li>
                                 <li>Happiness Meter</li>
                                 <li>Multi Way Routing</li>
                                 <li>Search by building address</li>
                               </ul>`,
                    params: {
                        enableScrolling: false
                    }
                },
                {
                    target: '#tour_search',
                    header: {
                        title: 'Search',
                    },
                    content: `Search by Makani Number, Place Name or Plot Number`,
                    params: {
                        enableScrolling: false
                    }
                },
                {
                    target: '#micBtn',
                    header: {
                        title: 'Voice Search',
                    },
                    content: `Click to search by voice`,
                    params: {
                        enableScrolling: false
                    }
                },
                {
                    target: '#ToolBarSearchDirection',
                    header: {
                        title: 'Directions',
                    },
                    content: `Click to open directions panel`,
                    params: {
                        enableScrolling: false
                    }
                },
                {
                    target: '#current_location',
                    header: {
                        title: 'Current Location',
                    },
                    content: `Click here to display the current location`,
                    params: {
                        enableScrolling: false
                    }
                },
                {
                    target: '#types_menu',
                    header: {
                        title: 'Map Layers',
                    },
                    content: `<ul>
                                <li>Change map view to satellite view</li>
                                <li>Enable/Disable Traffic</li>
                                <li>Enable/Disable Transit</li>
                              </ul>`,
                    params: {
                        placement: 'left',
                        enableScrolling: false
                    }
                },
                {
                    //target: '.H_l_right.H_l_middle.H_l_vertical',
                    target: '.gmnoprint',
                    header: {
                        title: 'Zoom in/out',
                    },
                    content: `Click + to zoom the map in and - to zoom the map out`,
                    params: {
                        enableScrolling: false
                    }
                },
                {
                    target: '.happinessFloatDiv',
                    header: {
                        title: 'Happiness Meter'
                    },
                    content: `Click to submit your feedback`,
                    params: {
                        placement: 'left',
                        enableScrolling: false
                    }
                },
                {
                    target: '#tour_map',
                    header: {
                        title: 'Map Tap',
                    },
                    content: `Tap in the middle of the building to display makani number of the main entrances`,
                    params: {
                        enableScrolling: false
                    }
                },
                {
                    target: '#tour_map',
                    header: {
                        title: 'Map Long Press',
                    },
                    content: `Click and hold to select map point`,
                    params: {
                        enableScrolling: false
                    }
                }
            ],



            tour_building_callbacks: {
                onFinish: function () {
                    localStorage.setItem("tour_building_done", true);
                },
                onSkip: function () {
                    localStorage.setItem("tour_building_done", true);
                }
            },
            tour_building_steps: [
                {
                    target: '#buildingaddress_search',
                    header: {
                        title: 'Location details',
                    },
                    content: `Search by community Name/Number,street,Building Number`,
                    params: {
                        enableScrolling: false
                    }
                }
            ],
            tour_routing_callbacks: {
                onFinish: function () {
                    localStorage.setItem("tour_routing_done", true);
                },
                onSkip: function () {
                    localStorage.setItem("tour_routing_done", true);
                }
            },
            tour_routing_steps: [
                {
                    target: '#tour_routing_input',
                    header: {
                        title: 'Search',
                    },
                    content: `Search by Makani Number, Place Name or Plot Number`,
                    params: {
                        placement: 'top',
                        enableScrolling: false
                    }
                },
                {
                    target: '#tour_routing_currentLocation',
                    header: {
                        title: 'Current Location',
                    },
                    content: `Click here to add the current location`,
                    params: {
                        placement: 'left',
                        enableScrolling: false
                    }
                },
                {
                    target: '#tour_routing_switch',
                    header: {
                        title: 'Switch the destination',
                    },
                    content: `Switch the destinations to change the order and re-calculate the route again`,
                    params: {
                        placement: 'left',
                        enableScrolling: false
                    }
                },
                /*
                {
                    target: '#tour_routing_add',
                    header: {
                        title: 'Add Destination',
                    },
                    content: `Click to add a new destination and re-calculate the route again`,
                    params: {
                        placement: 'bottom',
                        enableScrolling: false
                    }
                },
                */
                {
                    target: '#tour_routing_salik',
                    header: {
                        title: 'Salik',
                    },
                    content: `Route with/without Salik`,
                    params: {
                        //placement: 'bottom',
                        enableScrolling: false
                    }
                },
                {
                    target: '#tour_routing_type',
                    header: {
                        title: 'Route type',
                    },
                    content: `Calculate the route for car or walk`,
                    params: {
                        //placement: 'bottom',
                        enableScrolling: false
                    }
                },
                {
                    target: '#tour_routing_fastshort',
                    header: {
                        title: 'Fastest/Shortest',
                    },
                    content: `calculate the fastest/shortest route`,
                    params: {
                        //placement: 'bottom',
                        enableScrolling: false
                    }
                },
                {
                    target: '#tour_routing_close',
                    header: {
                        title: 'Close',
                    },
                    content: `Click to navigate to the main screen`,
                    params: {
                        //placement: 'bottom',
                        enableScrolling: false
                    }
                }
            ],


            //Tour info
            tour_info_callbacks: {
                onFinish: function () {
                    localStorage.setItem("tour_info_done", true);
                },
                onSkip: function () {
                    localStorage.setItem("tour_info_done", true);
                }
            },
            tour_info_steps: [

            ],


            //Tour drawer
            tour_drawer_callbacks: {
                onFinish: function () {
                    localStorage.setItem("tour_drawer_done", true);
                },
                onSkip: function () {
                    localStorage.setItem("tour_drawer_done", true);
                }
            },
            tour_drawer_steps: [
                {
                    target: '#drawer_directions',
                    header: {
                        title: 'Directions',
                    },
                    content: `Click to open directions panel`,
                    params: {
                        //placement: 'bottom',
                        enableScrolling: false
                    }
                },
                /*
                {
                    target: '#tour_info_streetview',
                    header: {
                        title: 'Street view',
                    },
                    content: `click on the image to display the street view of the selected entrance`,
                    params: {
                        placement: 'bottom',
                        enableScrolling: false
                    }
                },
                {
                    target: '#tour_info_share',
                    header: {
                        title: 'Share Location',
                    },
                    content: `Share location info (Makani Number,Address,Place Name, etc.) to others by using other applications`,
                    params: {
                        placement: 'top',
                        enableScrolling: false
                    }
                }
                */
            ],


            //Tour favorite
            tour_favorite_callbacks: {
                onFinish: function () {
                    localStorage.setItem("tour_favorite_done", true);
                },
                onSkip: function () {
                    localStorage.setItem("tour_favorite_done", true);
                }
            },
            tour_favorite_steps: [
                {
                    target: '#tour_favorite_text',
                    header: {
                        title: 'Show on Map',
                    },
                    content: `Click to show the favorite on map`,
                    params: {
                        placement: 'left',
                        enableScrolling: false
                    }
                },
                {
                    target: '#tour_favorite_edit',
                    header: {
                        title: 'Edit Favorite',
                    },
                    content: `Click to edit the favorite`,
                    params: {
                        placement: 'right',
                        enableScrolling: false
                    }
                },
                {
                    target: '#tour_favorite_delete',
                    header: {
                        title: 'Delete Favorite',
                    },
                    content: `Click to delete the favorite`,
                    params: {
                        placement: 'right',
                        enableScrolling: false
                    }
                },
            ],


            refreshpopover: 0,
            categoryImageSrs: global.hostAddress + "/Images/MakaniCategories/default.png",
            snackbar_no_result_found: false,
            snackbar_no_result_found_text: "Sorry, Makani can't find any result",
            drawer: false,
            dialog_favorite: false,
            dialog_building_address: false,
            dialog_store_redirect_iphone: false,
            dialog_store_redirect: false,
            dialog_desclaimer: false,
            dialog_download: false,
            dialog_about: false,
            dialog_about_mobile: false,
            dialog_contactus: false,
            dialog_sitemap: false,
            dialog_faq: false,
            dialog_help: false,
            dialog_legend: false,
            dialog_happiness: false,
            dialog_contrast: false,
            window: 0,
            MenuMapTypes: false,
            //speed-wheel-popupmenu
            direction: 'top',
            fab: false,
            fling: false,
            hover: false,
            tabs: null,
            top: false,
            right: false,
            bottom: false,
            left: false,
            transition: 'slide-y-reverse-transition',
            intervel: {},
            value: 0,

            descriptionLimit: 35,

            entries: [],
            isAutoCompleteLoading: false,
            model: null,
            //search: null,
            //items: [],
            select: null,
            states: [
                'Alabama',
                'Alaska',
                'American Samoa'],
            //items: [
            //    { title: 'Home', icon: 'dashboard' 
            //    { title: 'About', icon: 'question_answer' }
            //]

            //new search auto complete
            search_items: [],
            search_model: null,
            search: null,

            TSearchMicOn: false,
            TSearchMicOff: false,
            ToolbarSearchDetailProgress: false,
            TSearchClear: false,
            TSearchDirection: true,

            isAutoCompleteEnabled: true,
            sheet: false,
            tiles: [
                { img: 'Email.png', title: 'Email' },
                { img: 'facebook.png', title: 'Facebook' },
                { img: 'twitter.png', title: 'Twitter' }
            ],
            //search detail section for basic data
            topIconToShowRoutingPanel: false,
            topArrowToShowDetailDIv: false,
            IsQuickSearchDetailDivVisible: false,
            TapOnMapBlinkingValue: "Tap on any map pin to view entrance details",
            IsBasicLocationNameLabelVisible: false,
            BasicLocationNameValue: "",
            IsBasicEmirateLabelVisble: false,
            BasicEmirateValue: "",
            IsBasicCommunityNameLabelVisible: false,
            BasicCommunityNameValue: "",
            IsBasicCallSectionVisible: false,
            BasicPhoneValue: "",
            IsBasicEmailSectionVisible: false,
            IsBasicUrlSectionVisible: false,
            BasicWebsiteValue: "",
            IsBasicLandNumberLabelVisible: false,
            BasicLandNumberValue: "",

            //Search detail section for makani related data
            IsMakaniInfoSectionVisible: false,
            IsMakaniPlateVisible: false,
            MakaniPlateValue: "",
            BuildingEntranceNameValue: "",
            MakaniAddressValue: "",
            // IsMakaniStreetLevelSectionVisible:false,


            //Zone code result section
            IsZoningRegulationSectionVisible: false,
            ZoneCodeValue: "",
            CoastalDetailValue: "",
            MetroDetailValue: "",
            HeightValue: "",
            LandUseValue: "",
            ParkingValue: "",
            SetBackValue: "",
            RemarkValue: "",

            ZoneCodeValue2: "",
            CoastalDetailValue2: "",
            MetroDetailValue2: "",
            HeightValue2: "",
            LandUseValue2: "",
            ParkingValue2: "",
            SetBackValue2: "",
            RemarkValue2: "",

            ClickedLandNumberValue: "",

            IsRemarksRegEnnVisisble: false,
            IsSetbackRegEnVisisble: false,
            IsParkingRegEnVisisble: false,
            IsLanduseRegEnVisisble: false,
            IsHeightRegEnVisisble: false,
            IsDescVisisble: false,
            IsZoneCodeVisisble: false,
            IsMetroDescVisible: false,

            IsRemarksRegEnnVisisble2: false,
            IsSetbackRegEnVisisble2: false,
            IsParkingRegEnVisisble2: false,
            IsLanduseRegEnVisisble2: false,
            IsHeightRegEnVisisble2: false,
            IsDescVisisble2: false,
            IsZoneCodeVisisble2: false,
            IsMetroDescVisible2: false,

            //Map single tap popup value
            IsMapSingleTapInfoSectionVisible: false,

            //Map long Click location popup values
            IsMapLongClickInfoSectionVisible: false,
            IsMapclickMakaniPlateVisible: false,
            MapLongClickMakaniNumbereValue: "",
            MapLongClickTitleValue1: "",
            MapLongClickTitleValue2: "",
            MapLongClickTitleValue3: "",
            // sharing url sample = "http://www.makani.ae/home?mc=121212&lc=12323"
            // SharingBaseURl: window.location.protocol + "//" + window.location.host+"/home/Map",
            SharingBaseURl: global.hostAddress + "q",
            SharingURl: "",

            //building address search components
            community_search_model: "",
            street_search_model: "",
            building_search_model: "",
            community_search_items: [],
            street_search_items: [],
            building_search_items: [],
            iscommunity_search_loading: false,
            isstreet_search_loading: false,
            isbuilding_search_loading: false,
            isstreet_search_visible: false,
            isbuidling_search_visible: false,
            DoCommunitySearch: null,
            DoBuildingSearch: null,
            DoStreetSearch: null,

            //Routing component
            routingsearch_model0: "",
            routingsearch_model1: "",
            routingsearch_model2: "",
            routingsearch_model3: "",
            routingsearch_model4: "",


            isRouting0Loading: false,
            isRouting1Loading: false,
            isRouting2Loading: false,
            isRouting3Loading: false,
            isRouting4Loading: false,


            isRouting_0_Isvisible: true,
            isRouting_1_Isvisible: true,
            isRouting_2_Isvisible: false,
            isRouting_3_Isvisible: false,
            isRouting_4_Isvisible: false,

            makaniDirectionIconeShow: false,


            IsRoutingDivVisible: false,

            search_routing_items0: [],
            search_routing_items1: [],
            search_routing_items2: [],
            search_routing_items3: [],
            search_routing_items4: [],

            nonEmptycountSearchBox: 2,


            routingsearch_model0_latlong_data: "",
            routingsearch_model1_latlong_data: "",
            routingsearch_model2_latlong_data: "",
            routingsearch_model3_latlong_data: "",
            routingsearch_model4_latlong_data: "",


            DoRouteSearchOnFirst: null,
            DoRouteSearchOnSecond: "Type 4 characters",
            DoRouteSearchOnThird: null,
            DoRouteSearchOnFourth: null,
            DoRouteSearchOnFifth: null,
            toggle_routing_model: 0,
            toggle_routing_type_model: 0,
            toggle_contrast_model: 123,
            streetFullViewDiv: false,
            isStreetPreviewVisisble: false,
            streetLevelCurrentLocation: [48.8733641244471, 2.294754032045603],
            isStreetMapTapDivVisible: false,
            isStreetMapLongTapDivVisible: false,
            isToShowFooter: false,
            IsBasicStreetSectionVisible: false,
            isBasicStreetPreviewVisible: false,
            isMapTypeNormalVisible: false,
            isMapTypeSatelliteVisible: true,
            salikswitch: false,
            isSalikSwitchVisible: true,

            isShareBtnVisible: true,
            fav_saveloading: false,
            fav_icn_color: "green",
            favorite_txt: "Save",
            fav_hover_title: "add to favorite",
            dialog_favorite_input: false,
            favorite_name_input_value: "enter favorite name",
            favorite_buildingname_E: "",
            favorite_buildingname_A: "",
            visibleFavoriteAdd: false,
            visibleFavoriteDelete: false,
            currentFavType: "",
            currentFavName: "",
            user_favorite_data: [],
            dialog_fontresize: false,
            toggle_font_btns: 2,
            WebreaderDivVisible: false,
            topArrowToShowRoutingDIv: true,
            IsCollapsingRouting: false,
            logoutDialog: false,
            logoutSuccess: false,
            voiceSearchEnabled: false,
            loginErrorDialog: false,
            addFavoriteSuccess: false,
            currentRouteSearchBox: "",
            routingCurrentLocationPosition: undefined,
            deleteFavDeffered: false,
            deleteFavoriteDialog: false,
            deleteFavoriteSuccess: false,
            addFavoriteError: false,
            deleteFavoriteError: false,
            tourDeffered: jQuery.Deferred(),
            buildingTourDeffered: jQuery.Deferred(),
            routingTourDeffered: jQuery.Deferred(),
            infoTourDeffered: jQuery.Deferred(),
            favoriteTourDeffered: jQuery.Deferred()
        };

    },
    mounted: function () {

        this.initMainTour();

        detectScreenType();
        if (global.DeviceScreenType === "PC") {
            this.isToShowFooter = true;
            this.tourDeffered.resolve();
        }
        else {
            this.isToShowFooter = true;
            if (global.DeviceScreenType === "Android") {
                this.dialog_store_redirect = true;
            } else if (global.DeviceScreenType === "Iphone") {
                this.dialog_store_redirect_iphone = true;
            }
        }

        this.initBuildingTour();

        this.initRoutingTour();


        this.initFavoriteTour();
        this.initInfoTour();

        this.initDrawerTour();


        this.getFavorites(global.appUserId, global.appSessionId);

        this.toggle_contrast_model = localStorage.getItem('toggle_contrast_model') || "1";
        var fontType = localStorage.getItem('toggle_font_btns') || 3;
        this.toggle_font_btns = fontType - 1;

        this.resizeFont(this.toggle_font_btns + 1);
        this.adjustContrast();


        this.$forceUpdate();

        //vm.SetRoutingLatLongData('routingsearch_model0', [global.currentDeviceLongitude, global.currentDevicelatitude]);
        //addDraggableMarker('routingsearch_model0', global.currentDevicelatitude, global.currentDeviceLongitude, true);

    },
    methods: {
        checkDrawerTour: function (val) {
            /*
            if (val == true)
                this.drawerTourDeffered.resolve();
            else
                vm.$tours['tour_drawer'].stop();
            */
        },
        initDrawerTour: function () {
            /*
            this.drawerTourDeffered = jQuery.Deferred();

            this.drawerTourDeffered.promise().then(function () {
                var tour_done = localStorage.getItem("tour_drawer_done");
                if (!tour_done || tour_done == "false")
                    vm.$tours['tour_drawer'].start();

                vm.initDrawerTour();
            });
            */
        },
        initFavoriteTour: function () {
            this.favoriteTourDeffered = jQuery.Deferred();

            this.favoriteTourDeffered.promise().then(function () {
                var tour_done = localStorage.getItem("tour_favorite_done");
                if ((!tour_done || tour_done == "false") && global.userFavorites.length > 0)
                    vm.$tours['tour_favorite'].start();

                vm.initFavoriteTour();
            });
        },
        initInfoTour: function () {
            this.infoTourDeffered = jQuery.Deferred();

            this.infoTourDeffered.promise().then(function () {
                var tour_done = localStorage.getItem("tour_info_done");
                if (!tour_done || tour_done == "false")
                    vm.$tours['tour_info'].start();

                vm.initInfoTour();
            });
        },
        initRoutingTour: function () {
            this.routingTourDeffered = jQuery.Deferred();

            this.routingTourDeffered.promise().then(function () {
                var tour_done = localStorage.getItem("tour_routing_done");
                if (!tour_done || tour_done == "false")
                    vm.$tours['tour_routing'].start();

                vm.initRoutingTour();
            });
        },
        initBuildingTour: function () {
            this.buildingTourDeffered = jQuery.Deferred();

            this.buildingTourDeffered.promise().then(function () {
                var tour_done = localStorage.getItem("tour_building_done");
                if (!tour_done || tour_done == "false")
                    vm.$tours['tour_building'].start();

                vm.initBuildingTour();
            });
        },
        initMainTour: function () {
            this.tourDeffered = jQuery.Deferred();

            this.tourDeffered.promise().then(function () {
                var tour_done = localStorage.getItem("tour_main_done");
                if (!tour_done || tour_done == "false")
                    vm.$tours['tour_main'].start();

                vm.initMainTour();
            });
        },
        micclick: function (evt) {
            speech.startCapture();
        },
        loadFavDatatoVueObj: function (favlist) {
            this.user_favorite_data = favlist;
        },
        adjustContrast: function () {
            switch (this.toggle_contrast_model) {
                case "1":
                    $('HTML').removeClass("grayscale_filter");
                    $('HTML').removeClass("invert_filter");
                    break;
                case "2":
                    $('HTML').removeClass("invert_filter");
                    $('HTML').addClass("grayscale_filter");
                    break;
                case "3":
                    $('HTML').removeClass("grayscale_filter");
                    $('HTML').addClass("invert_filter");
                    break;
            }
            localStorage.setItem('toggle_contrast_model', this.toggle_contrast_model);
        },
        resizeFont: function (type) {
            var dc = document.getElementsByTagName("HTML")[0];
            switch (type) {
                case 1:
                    dc.style.fontSize = "12px";
                    break;
                case 2:
                    dc.style.fontSize = "14px";
                    break;
                case 3:
                    dc.style.fontSize = "16px"; //normal
                    break;
                case 4:
                    dc.style.fontSize = "18px";
                    break;
                case 5:
                    dc.style.fontSize = "20px";
                    break;

            }
            localStorage.setItem('toggle_font_btns', type);
            // this.dialog_fontresize = false;
        },
        FavoriteItemClick: function (favItem) {
            if (favItem.FavType == "MAKANI") {
                var dgsid = favItem.FavValue.replace(/\s/g, '');
                this.OnSearchItemClick(dgsid, "2", "");
            } else { //Map point
                var modelShareLocation = {
                    InputJson: {
                        Name: "queryy",
                        Latitude: favItem.Location.split(",")[0],
                        Longitude: favItem.Location.split(",")[1],
                        UserId: "0",
                        sessionid: ""
                    },
                    Token: "l4f76613re4junvvbbd4ufki1j!=+=o6JGpy02dppzxKfVibRYfQ==",
                    Remarks: "MAKANI PHASE 2"
                };

                vm.PrepareForAjaxRequest("GetMapLongPressLocationInfo", modelShareLocation, "", "", "");
            }
        },
        //if actiontype is 'delete' then delete selected location from favorite
        //if actiontype is 'LabelFavoriteButton' then decide to show save or remove btn
        //selectedValue is either makani number or location lat,lon values
        doActionWithSelectedLocationAndFavorites: function (actionType, selectedValue, isMakani, isLocation) {
            var isLocationListedInFavorite = false;

            //iterate json and check location has already added
            if (this.user_favorite_data.length > 0) {
                for (i = 0; i < this.user_favorite_data.length; i++) {
                    var favItem = this.user_favorite_data[i];
                    if (isMakani) {
                        if (favItem.FavType == "MAKANI") {
                            if (favItem.FavValue == selectedValue) {
                                if (actionType == "delete") {
                                    this.deleteFavoriteRequest(favItem);
                                } if (actionType == "LabelFavoriteButton") {
                                    isLocationListedInFavorite = true;
                                    this.visibleFavoriteDelete = true;
                                    this.visibleFavoriteAdd = false;
                                }
                            }
                        }
                    } if (isLocation) {
                        if (favItem.FavType == "LOCATION") {
                            if (favItem.Location == selectedValue) {
                                if (actionType == "delete") {
                                    this.deleteFavoriteRequest(favItem);
                                } if (actionType == "LabelFavoriteButton") {
                                    isLocationListedInFavorite = true;
                                    this.visibleFavoriteDelete = true;
                                    this.visibleFavoriteAdd = false;
                                }
                            }
                        }
                    }

                }

            }
            if (!isLocationListedInFavorite && (actionType == "LabelFavoriteButton")) {
                this.visibleFavoriteDelete = false;
                this.visibleFavoriteAdd = true;
            }


        },
        removeFavItemFromFavoritesArray: function (favItem) {
            for (var i = 0; i < this.user_favorite_data.length; i++) {
                if (this.user_favorite_data[i].FavValue == favItem.FavValue) {
                    this.user_favorite_data.splice(i, 1);
                    return;
                }
            }
        },
        deleteFavoriteRequest: function (favItem, requestorigin) {

            //if (!confirm("Are you sure you want to delete this favorite?"))
            //    return;

            this.deleteFavDeffered = jQuery.Deferred();

            this.deleteFavoriteDialog = true;

            this.deleteFavDeffered.promise().then(function () {

                vm.removeFavItemFromFavoritesArray(favItem);

                var FavReqParam = {
                    InputJson: {
                        Favorites: vm.user_favorite_data,
                        UserId: global.appUserId,
                        SessionId: global.appSessionId
                    },
                    Token: "l4f76613re4junvvbbd4ufki1j!=+=o6JGpy02dppzxKfVibRYfQ==",
                    Remarks: "MAKANI PHASE 2"
                };
                if (requestorigin == "favoritePopup") {
                    vm.PrepareForAjaxRequest("DeleteFromFavoritePopup", FavReqParam, "", "", "", favItem);
                } else {
                    vm.PrepareForAjaxRequest("DeleteFavorite", FavReqParam, "", "", "", favItem);
                }

                vm.deleteFavoriteDialog = false;

                vm.deleteFavoriteSuccess = true;
                setTimeout(function () { vm.deleteFavoriteSuccess = false; }, 2000);
            });
        },
        syncFavorites: function (favItem, requestorigin) {
            var FavReqParam = {
                InputJson: {
                    Favorites: this.user_favorite_data,
                    UserId: global.appUserId,
                    SessionId: global.appSessionId
                },
                Token: "l4f76613re4junvvbbd4ufki1j!=+=o6JGpy02dppzxKfVibRYfQ==",
                Remarks: "MAKANI PHASE 2"
            };

            this.PrepareForAjaxRequest("SaveFavorite", FavReqParam, "", "", "", favItem);
        },
        getFavorites: function (userid, sessionid) {

            var FavReqParam = {
                InputJson: {
                    UserId: userid,
                    SessionId: sessionid
                },
                Token: "l4f76613re4junvvbbd4ufki1j!=+=o6JGpy02dppzxKfVibRYfQ==",
                Remarks: "MAKANI PHASE 2"
            };
            this.PrepareForAjaxRequest("GetFavorite", FavReqParam, "", "", "");
        },
        //this methods calls from detail section only
        deleteFavorite: function () {
            lat = this.routingsearch_model1_latlong_data.split(",")[0];
            lon = this.routingsearch_model1_latlong_data.split(",")[1];
            mSelectedValue = lat + "," + lon;
            mIsmakani = false;
            mIsLocation = false;

            if (this.IsMakaniInfoSectionVisible || this.IsMapclickMakaniPlateVisible) {
                mIsmakani = true;
                mSelectedValue = this.MakaniPlateValue || global.favMakaniNumber;
            } else {
                mIsLocation = true;
                mSelectedValue = global.favLongLocation;//global.favSeqNo;
            }


            this.doActionWithSelectedLocationAndFavorites("delete", mSelectedValue, mIsmakani, mIsLocation);
        },
        saveLocationToFavorite: function () {
            var lat = this.routingsearch_model1_latlong_data.split(",")[0] || global.favLat;
            var lon = this.routingsearch_model1_latlong_data.split(",")[1] || global.favLng;
            favname = this.favorite_name_input_value;
            buildingnameE = this.favorite_buildingname_E;
            buildingnameAr = this.favorite_buildingname_A;
            favtype = "Location";
            if (this.IsMakaniInfoSectionVisible || (this.IsMapSingleTapInfoSectionVisible && this.IsMapclickMakaniPlateVisible)) {
                favtype = "MAKANI";
                favvalue = this.MakaniPlateValue || global.favMakaniNumber;
            } else {
                favtype = "LOCATION";
                favvalue = global.favSeqNo;
                lat = global.favLocationLat;
                lon = global.favLocationLng;
            }

            if (this.user_favorite_data == undefined)
                this.user_favorite_data = [];

            var favItem = {
                FavName: favname,
                BuildingNameA: buildingnameAr,
                BuildingNameE: buildingnameE,
                CommAr: buildingnameAr,
                CommEn: buildingnameE,
                Location: lat + ',' + lon,
                FavType: favtype,
                FavValue: favvalue,
                LastUpdated: new Date().getTime()
            };

            //becuase of DB column restriction in MAKANI_FAVOURITE table
            /*var favItem = {
                FavName: favname,
                BuildingNameA: buildingnameAr.toString().substring(0, 49),
                BuildingNameE: buildingnameE.toString().substring(0, 98),
                CommAr: buildingnameAr.toString().substring(0, 49),
                CommEn: buildingnameE.toString().substring(0, 98),
                Location: lat + ',' + lon,
                FavType: favtype,
                FavValue: favvalue,
                LastUpdated: new Date().getTime()
            };*/

            this.user_favorite_data.push(favItem);

            var FavReqParam = {
                InputJson: {
                    Favorites: this.user_favorite_data,
                    UserId: global.appUserId,
                    SessionId: global.appSessionId
                },
                Token: "l4f76613re4junvvbbd4ufki1j!=+=o6JGpy02dppzxKfVibRYfQ==",
                Remarks: "MAKANI PHASE 2"
            };

            this.PrepareForAjaxRequest("SaveFavorite", FavReqParam, "", "", "", favItem);
        },
        login: function () {
            window.location.href = global.hostAddress + 'Account/Login';
            //this.isLogin = false;
        },
        logout: function () {
            this.logoutDialog = true;
        },
        doLogout: function () {
            this.logoutDialog = false;
            this.logoutSuccess = true,
                setTimeout(function () {
                    window.location.href = global.hostAddress + 'Account/Logout';
                }, 2000);
        },
        showAboutUsPage: function () {
            if (global.DeviceScreenType === "Mobile" || global.DeviceScreenType === "Android" ||
                global.DeviceScreenType === "Iphone" || global.DeviceScreenType === "Ipad") {
                this.dialog_about_mobile = true;
            } else {
                this.dialog_about = true;
            }
        },
        forceRerender: function () {
            this.refreshpopover += 1;
        },
        showStreetLevelView: function () {
            if (global.IsStreetLevelViewIsAvailable)
                this.streetFullViewDiv = true;
            else
                this.streetFullViewDiv = false;
            return;

            //Tried this for showing virtual plate in google maps streetview. but it was not possible due to binding of controls.
            //so we have developed separate html page
            var modelVirtualPlate = {
                "InputJson": {
                    "searchtext": "",
                    "currentlocation": global.CurrentSreetLatitude + "," + global.CurrentSreetLongitude,
                    "distancetype": "KM",
                    "level": "1",
                    "distance": "100",
                    "featureclass_id": "(2)",
                    "userid": "",
                    "sessionid": ""
                },
                "Token": "l4f76613re4junvvbbd4ufki1j!=+=o6JGpy02dppzxKfVibRYfQ==",
                "Remarks": "MAKANI PHASE 2 Test"
            };

            this.PrepareForAjaxRequest("VirtualPlate", modelVirtualPlate, "", "");
        },
        makePhoneCall: function () {
            window.open("tel:" + this.BasicPhoneValue, '_parent');
        },
        redirectToUrl: function () {
            window.open(this.BasicWebsiteValue, '_blank');
        },
        setRoutingCurrentLocation: function (position) {
            this.routingCurrentLocationPosition = position;
            this.goToCurrentLocation();
        },
        goToCurrentLocation: function () {
            var options = {
                enableHighAccuracy: true,
                timeout: 5000,
                maximumAge: 0
            };

            if (navigator.geolocation)
                navigator.geolocation.getCurrentPosition(this.showPosition, null, options);
        },
        showPosition: function (position) {
            var locationchanged = false;
            if (global.currentDevicelatitude != position.coords.latitude || global.currentDeviceLongitude != position.coords.longitude)
                locationchanged = true;

            global.currentDevicelatitude = position.coords.latitude;
            global.currentDeviceLongitude = position.coords.longitude;
            movetoCurrentLocation(global.currentDevicelatitude, global.currentDeviceLongitude, locationchanged);

            map.setCenter({ lat: global.currentDevicelatitude, lng: global.currentDeviceLongitude });
            if (global.DeviceScreenType === "PC")
                map.setZoom(global.pcZoom);
            else
                map.setZoom(global.mobileZoom);

            if (this.routingCurrentLocationPosition != undefined) {
                removeMapPointMarker("routingsearch_model" + this.routingCurrentLocationPosition);
                if (this["routingsearch_model" + this.routingCurrentLocationPosition] != "Your Location") {
                    this["routingsearch_model" + this.routingCurrentLocationPosition] = "Your Location";
                    //this.SetRoutingLatLongData('routingsearch_model' + this.routingCurrentLocationPosition, [global.currentDeviceLongitude, global.currentDevicelatitude]);
                    //addDraggableMarker('routingsearch_model' + this.routingCurrentLocationPosition, global.currentDevicelatitude, global.currentDeviceLongitude, true, true);

                    this['routingsearch_model' + this.routingCurrentLocationPosition + '_latlong_data'] = 'current';

                    addDraggableMarker("", global.currentDevicelatitude, global.currentDeviceLongitude, true, true, false, false);

                    this.routingCurrentLocationPosition = undefined;

                    this.nonEmptycountSearchBox = this.getNonEmpltyCountRouteSearchBox();

                    this.calculateRoute();
                }
            } else {

            }

            sendEventToGoogleAnalytics("Current Location", "Current Location Click", "English");
        },
        setFallBackAttributes: function (lat, lon, distance, title, emirate) {
            global.CurrentSreetLatitude = Number(lat);
            global.CurrentSreetLongitude = Number(lon);
            global.clickedFallBackDistance = distance;
            global.clickedFallbackTitle = title;
            global.clickedFallbackEmirate = emirate;

            // this.PrepareForAjaxRequest("GetShareLocationSquenceNumber", "", "", "", "");
        },
        setCategoryImage: function (categoryType) {
            this.categoryImageSrs = global.hostAddress + "/Images/MakaniCategories/default.png";
            if (categoryType) {
                if (categoryType.toLowerCase().indexOf("accomodation") >= 0) {
                    this.categoryImageSrs = global.hostAddress + "/Images/MakaniCategories/accomodation.jpg";
                }
                if (categoryType.toLowerCase().indexOf("architecture") >= 0) {
                    this.categoryImageSrs = global.hostAddress + "/Images/MakaniCategories/architecture.jpg";
                }
                if (categoryType.toLowerCase().indexOf("business") >= 0) {
                    this.categoryImageSrs = global.hostAddress + "/Images/MakaniCategories/business.jpg";
                }
                if (categoryType.toLowerCase().indexOf("education") >= 0) {
                    this.categoryImageSrs = global.hostAddress + "/Images/MakaniCategories/education.jpg";
                }

            }

        },

        changeLngauge: function () {
            window.location.href = global.hostAddress + "home/maparabic";
            sendEventToGoogleAnalytics("Change Language", "Change Language Click", "English");
        },
        onSalikchange: function () {
            this.calculateRoute();
        },
        calculateRoute: function () {
            //if (global.currentLocationMarker)
            //    global.currentLocationMarker.setIcon(new H.map.Icon(global.hostAddress + '/Images/MapPins/currentlocation.png', { size: { w: global.currentLocationIconSize, h: global.currentLocationIconSize } }));

            if (global.currentLocationMarker) {
                var currLocnIcon = {
                    url: global.hostAddress + '/Images/MapPins/currentlocation.png'
                    //size: new google.maps.Size(global.makaniPinWidth, global.makaniPinHeight),
                    //origin: new google.maps.Point(0, 0),
                    //anchor: new google.maps.Point(0, global.makaniPinHeight)
                };
                global.currentLocationMarker.setIcon(currLocnIcon);
            }


            //alert("data=0 " + this.routingsearch_model0_latlong_data[0] + ", data 1=" + this.routingsearch_model1_latlong_data[1]);
            // alert(this.search_routing_items0.dgis_id[0]);
            var destinationpoints = [];
            if (this.isRouting_0_Isvisible && this.routingsearch_model0_latlong_data) {
                if (this.routingsearch_model0_latlong_data == 'current') {
                    destinationpoints.push(global.currentDevicelatitude + "," + global.currentDeviceLongitude);
                } else
                    destinationpoints.push(this.routingsearch_model0_latlong_data);
            }
            if (this.isRouting_1_Isvisible && this.routingsearch_model1_latlong_data)
                if (this.routingsearch_model1_latlong_data == 'current') {
                    destinationpoints.push(global.currentDevicelatitude + "," + global.currentDeviceLongitude);
                } else
                    destinationpoints.push(this.routingsearch_model1_latlong_data);
            if (this.isRouting_2_Isvisible && this.routingsearch_model2_latlong_data)
                if (this.routingsearch_model2_latlong_data == 'current') {
                    destinationpoints.push(global.currentDevicelatitude + "," + global.currentDeviceLongitude);
                } else
                    destinationpoints.push(this.routingsearch_model2_latlong_data);
            if (this.isRouting_3_Isvisible && this.routingsearch_model3_latlong_data)
                if (this.routingsearch_model3_latlong_data == 'current') {
                    destinationpoints.push(global.currentDevicelatitude + "," + global.currentDeviceLongitude);
                } else
                    destinationpoints.push(this.routingsearch_model3_latlong_data);
            if (this.isRouting_4_Isvisible && this.routingsearch_model4_latlong_data)
                if (this.routingsearch_model4_latlong_data == 'current') {
                    destinationpoints.push(global.currentDevicelatitude + "," + global.currentDeviceLongitude);
                } else
                    destinationpoints.push(this.routingsearch_model4_latlong_data);

            if (destinationpoints.length >= 2) {

                if (destinationpoints.length > 2) {
                    for (k = 1; k <= destinationpoints.length - 2; k++) {
                        updateMapPointMarkerIcon(destinationpoints[k].split(",")[0], destinationpoints[k].split(",")[1], k);
                    }
                }

                if (this.toggle_routing_model == 0) {
                    if (this.salikswitch)
                        calculateRouteOnMap(destinationpoints, "noSalik");
                    else
                        calculateRouteOnMap(destinationpoints, "car");
                }
                if (this.toggle_routing_model == 1)
                    calculateRouteOnMap(destinationpoints, "walk");
            }
        },
        clearRouteSearchBox: function (position, reset) {

            switch (position) {
                case 0:
                    this.routingsearch_model0 = "";
                    this.routingsearch_model0_latlong_data = "";
                    removeMapPointMarker("routingsearch_model0");
                    break;
                case 1:
                    this.routingsearch_model1 = "";
                    this.routingsearch_model1_latlong_data = "";
                    removeMapPointMarker("routingsearch_model1");
                    break;
                case 2:
                    this.routingsearch_model2 = "";
                    this.routingsearch_model2_latlong_data = "";
                    removeMapPointMarker("routingsearch_model2");
                    break;
                case 3:
                    this.routingsearch_model3 = "";
                    this.routingsearch_model3_latlong_data = "";
                    removeMapPointMarker("routingsearch_model3");
                    break;
                case 4:
                    this.routingsearch_model4 = "";
                    this.routingsearch_model4_latlong_data = "";
                    removeMapPointMarker("routingsearch_model4");
                    break;
            }

            if (!reset) {
                this.nonEmptycountSearchBox = this.getNonEmpltyCountRouteSearchBox();

                if (this.getNonEmpltyCountRouteSearchBox() < 2) {
                    //clear the route
                    removeAllRouteMapObjects();
                    if (routeInstructionsContainer)
                        clearRoutingDetails();
                    if (global.currentLocationMarker)
                        global.currentLocationMarker.setIcon(new H.map.Icon(global.hostAddress + '/Images/MapPins/currentlocation.png', { size: { w: global.currentLocationIconSize, h: global.currentLocationIconSize } }));

                } else {
                    this.calculateRoute();
                }
            }

        },
        getEmptyRouteSearchBox: function () {
            if (this.isRouting_0_Isvisible && this.routingsearch_model0_latlong_data == "") {
                return "routingsearch_model0";
            }
            if (this.isRouting_1_Isvisible && this.routingsearch_model1_latlong_data == "") {
                return "routingsearch_model1";
            }
            if (this.isRouting_2_Isvisible && this.routingsearch_model2_latlong_data == "") {
                return "routingsearch_model2";
            }
            if (this.isRouting_3_Isvisible && this.routingsearch_model3_latlong_data == "") {
                return "routingsearch_model3";
            }
            if (this.isRouting_4_Isvisible && this.routingsearch_model4_latlong_data == "") {
                return "routingsearch_model4";
            }

        },
        getNonEmpltyCountRouteSearchBox: function () {
            return this.getVisibleCountRouteSearchBox() - this.getEmptyCountRouteSearchBox();
        },
        getVisibleCountRouteSearchBox: function () {
            var counter = 0;
            if (this.isRouting_0_Isvisible) {
                counter++
            }
            if (this.isRouting_1_Isvisible) {
                counter++;
            }
            if (this.isRouting_2_Isvisible) {
                counter++;
            }
            if (this.isRouting_3_Isvisible) {
                counter++;
            }
            if (this.isRouting_4_Isvisible) {
                counter++;
            }

            return counter;
        },
        getEmptyCountRouteSearchBox: function () {
            var counter = 0;
            if (this.isRouting_0_Isvisible && this.routingsearch_model0_latlong_data == "") {
                counter++
            }
            if (this.isRouting_1_Isvisible && this.routingsearch_model1_latlong_data == "") {
                counter++;
            }
            if (this.isRouting_2_Isvisible && this.routingsearch_model2_latlong_data == "") {
                counter++;
            }
            if (this.isRouting_3_Isvisible && this.routingsearch_model3_latlong_data == "") {
                counter++;
            }
            if (this.isRouting_4_Isvisible && this.routingsearch_model4_latlong_data == "") {
                counter++;
            }

            return counter;

        },

        reAssignModels: function (isAdd) {
            var modelArray = [];
            var dataArray = [];
            for (var i = 0; i < 5; i++) {
                if (this["isRouting_" + i + "_Isvisible"] == true) {
                    modelArray.push(this["routingsearch_model" + i]);
                    dataArray.push(this["routingsearch_model" + i + "_latlong_data"]);
                }
            }

            for (var i = 0; i < 5; i++) {
                this["isRouting_" + i + "_Isvisible"] = false;
            }
            for (var i = 0; i < modelArray.length; i++) {
                this["routingsearch_model" + i] = modelArray[i];
                this["routingsearch_model" + i + "_latlong_data"] = dataArray[i];
                this["isRouting_" + i + "_Isvisible"] = true;

                updateMapPointMarker("routingsearch_model" + i, dataArray[i].split(",")[0], dataArray[i].split(",")[1]);
            }

            if (isAdd) {
                //Add empty one, no need to add marker
                this["routingsearch_model" + i] = "";
                this["routingsearch_model" + i + "_latlong_data"] = "";
                this["isRouting_" + i + "_Isvisible"] = true;
            }
        },


        switchDirections: function (position) {
            var modelArray = [];
            var valArray = [];

            modelArray.push("routingsearch_model" + (position - 1));
            modelArray.push("routingsearch_model" + position);

            this.swapValues(modelArray);

            valArray.push("routingsearch_model" + (position - 1) + "_latlong_data");
            valArray.push("routingsearch_model" + position + "_latlong_data");

            this.swapValues(valArray);

            updateMapPointMarker("routingsearch_model" + (position - 1), this["routingsearch_model" + (position - 1) + "_latlong_data"].split(",")[0], this["routingsearch_model" + (position - 1) + "_latlong_data"].split(",")[1]);
            updateMapPointMarker("routingsearch_model" + position, this["routingsearch_model" + position + "_latlong_data"].split(",")[0], this["routingsearch_model" + position + "_latlong_data"].split(",")[1]);

            this.calculateRoute();
        },

        swapValues: function (valArray) {
            var val = this[valArray[0]];
            this[valArray[0]] = this[valArray[1]];
            this[valArray[1]] = val;
        },

        addNewRouteSearchBox: function () {
            this.reAssignModels(true);
        },
        OnMakaniDirectionsClick: function () {
            if (!this.IsRoutingDivVisible) {
                this.ResizeRoutingDIvWidth();
                this.IsRoutingDivVisible = true;
                this.routingTourDeffered.resolve();

                //this.ResizeRoutingDIvWidth();

                this.isRouting_0_Isvisible = true;
                this.isRouting_1_Isvisible = true;

                if (global.currentDevicelatitude && global.currentDeviceLongitude) {
                    this.routingsearch_model0 = "Your Location";
                    //this.SetRoutingLatLongData("routingsearch_model0", [global.currentDeviceLongitude, global.currentDevicelatitude]);
                    this['routingsearch_model0_latlong_data'] = 'current';
                    addDraggableMarker("", global.currentDevicelatitude, global.currentDeviceLongitude, true, true, false, false);
                }

                var empty_search_model = global.currentDevicelatitude && global.currentDeviceLongitude ? "routingsearch_model1" : "routingsearch_model0";
                if (empty_search_model) {
                    var lat = "";
                    var lng = ""
                    var title = "";
                    if (this.IsMapclickMakaniPlateVisible) {
                        lat = global.MakaniLatitude;
                        lng = global.MakaniLongitude;
                        title = global.MakaniRouteNumber;
                    } else { //Map point
                        lat = global.CurrentSreetLatitude;
                        lng = global.CurrentSreetLongitude;
                        title = global.mapPointTitle;
                    }

                    this.SetRoutingLatLongData(empty_search_model, [lng, lat]);
                    this[empty_search_model] = title;

                    addDraggableMarker(empty_search_model, lat, lng, true);

                    this.IsMapLongClickInfoSectionVisible = false;
                    this.IsMapSingleTapInfoSectionVisible = false;
                    this.IsMapclickMakaniPlateVisible = false;

                    this.IsQuickSearchDetailDivVisible = false;

                    //this.calculateRoute();

                    this.calculateRoute();
                }
            }
        },
        removeRouteSearchBox: function (position, reset) {
            switch (position) {
                case "0":
                    if (this.isRouting_0_Isvisible) {
                        this.isRouting_0_Isvisible = false;
                        removeMapPointMarker("routingsearch_model0");
                        this.routingsearch_model0_latlong_data = "";
                        if (this.search_routing_items0 !== "")
                            this.search_routing_items0.length = 0;
                    }
                    break;
                case "1":
                    if (this.isRouting_1_Isvisible) {
                        this.isRouting_1_Isvisible = false;
                        removeMapPointMarker("routingsearch_model1");
                        this.routingsearch_model1_latlong_data = "";
                        if (this.search_routing_items1 !== "")
                            this.search_routing_items1.length = 0;
                    }
                    break;
                case "2":
                    if (this.isRouting_2_Isvisible) {
                        this.isRouting_2_Isvisible = false;
                        removeMapPointMarker("routingsearch_model2");
                        this.routingsearch_model2_latlong_data = "";
                        if (this.search_routing_items2 !== "")
                            this.search_routing_items2.length = 0;
                    }
                    break;
                case "3":
                    if (this.isRouting_3_Isvisible) {
                        this.isRouting_3_Isvisible = false;
                        removeMapPointMarker("routingsearch_model3");
                        this.routingsearch_model3_latlong_data = "";
                        if (this.search_routing_items3 !== "")
                            this.search_routing_items3.length = 0;
                    }
                    break;
                case "4":
                    if (this.isRouting_4_Isvisible) {
                        this.isRouting_4_Isvisible = false;
                        removeMapPointMarker("routingsearch_model4");
                        this.routingsearch_model4_latlong_data = "";
                        if (this.search_routing_items4 !== "")
                            this.search_routing_items4.length = 0;
                    }
                    break;
            }

            if (!reset) {
                this.reAssignModels();

                this.nonEmptycountSearchBox = this.getNonEmpltyCountRouteSearchBox();

                if (this.getNonEmpltyCountRouteSearchBox() < 2) {
                    //clear the route
                    removeAllRouteMapObjects();

                    if (global.currentLocationMarker)
                        global.currentLocationMarker.setIcon(new H.map.Icon(global.hostAddress + '/Images/MapPins/currentlocation.png', { size: { w: global.currentLocationIconSize, h: global.currentLocationIconSize } }));
                } else {
                    this.calculateRoute();
                }
            }

        },
        //DrawerClick: () => alert("assa")
        //var url=@Url.Action("Map", "Home");
        //  DrawerClick: () => alert("assa")
        opendialog: function () {
            //$("dialog_disclaimer").show();
            // $("dialog_download").hide();
            //this.dialog = true

        },
        beforeDestroy: function () {
            clearInterval(this.interval);
        },
        querySelections: function (v) {
            this.loading = true;
            // Simulated ajax query
            setTimeout(function () {
                this.items = this.states.filter(function (e) {
                    return (e || '').toLowerCase().indexOf((v || '').toLowerCase()) > -1
                });
                this.loading = false;
            }, 500);
        },
        listclick: function listclick() {
            alert('clicked');
        },

        isNullOrEmpty: function (data) {

            if (data) {
                var strData = String(data);
                if (strData.trim().length == 0 || strData == null) {
                    return true;
                } else {
                    return false;
                }
            } else {
                return true;
            }

        },
        shareUrl: function (type, language) {
            this.sheet = false;
            var baseUrl = "";
            if (this.IsMakaniInfoSectionVisible === true || this.IsMapclickMakaniPlateVisible === true) {
                var makaniNum = "";
                if (this.MakaniPlateValue) {
                    makaniNum = this.MakaniPlateValue.replace(/\s/g, '');
                    this.SharingURl = this.SharingBaseURl + "?l=E&m=" + makaniNum;
                } else if (this.MapLongClickMakaniNumbereValue) {
                    makaniNum = this.MapLongClickMakaniNumbereValue.replace(/\s/g, '');
                    this.SharingURl = this.SharingBaseURl + "?l=E&m=" + makaniNum;
                }
                else if (this.MapLongClickMakaniNumbereValue) {
                    makaniNum = this.MakaniPlateValue.replace(/\s/g, '');
                    this.SharingURl = this.SharingBaseURl + "?l=E&m=" + makaniNum;
                }
                switch (type) {
                    case "facebook":
                        baseUrl = "https://www.facebook.com/sharer/sharer.php?u=";
                        window.open(baseUrl + this.SharingURl, "popup", "width=600, height=400, scrollbars=no");
                        sendEventToGoogleAnalytics("Share to Facebook", "Share Click", "English");
                        break;
                    case "twitter":
                        baseUrl = "https://twitter.com/share?url=";
                        window.open(baseUrl + this.SharingURl, "popup", "width=600, height=400, scrollbars=no");
                        sendEventToGoogleAnalytics("Share to twitter", "Share Click", "English");
                        break;
                    case "email":
                        //check makani or nlat lon   
                        baseUrl = "mailto:?Subject=Makani&body=" + encodeURIComponent(this.SharingURl);
                        window.location.href = baseUrl;
                        sendEventToGoogleAnalytics("Share to Email", "Share Click", "English");
                        break;
                }

            } else {
                this.SharingURl = this.SharingBaseURl + "?l=E&sn=" + global.ShareSequenceNumber;

                switch (type) {
                    case "facebook":
                        baseUrl = "https://www.facebook.com/sharer/sharer.php?u=";
                        window.open(baseUrl + this.SharingURl, "popup", "width=600, height=400, scrollbars=no");
                        sendEventToGoogleAnalytics("Share to Facebook", "Share Click", "English");
                        break;
                    case "twitter":
                        baseUrl = "https://twitter.com/share?url=";
                        window.open(baseUrl + this.SharingURl, "popup", "width=600, height=400, scrollbars=no");
                        sendEventToGoogleAnalytics("Share to twitter", "Share Click", "English");
                        break;
                    case "email":
                        //check makani or nlat lon   
                        baseUrl = "mailto:?Subject=Makani&body=" + encodeURIComponent(this.SharingURl);
                        window.location.href = baseUrl;
                        sendEventToGoogleAnalytics("Share to Email", "Share Click", "English");
                        break;
                }

            }



        },
        ResetSearchUIPopOverValuesToDefault: function () {
            //search detail section for basic data
            this.topIconToShowRoutingPanel = false;
            this.topArrowToShowDetailDIv = false;
            this.IsQuickSearchDetailDivVisible = false;
            this.TapOnMapBlinkingValue = "Tap on any map pin to view entrance details";
            this.IsBasicLocationNameLabelVisible = false;
            this.BasicLocationNameValue = "";
            this.IsBasicEmirateLabelVisble = false;
            this.BasicEmirateValue = "";
            this.IsBasicCommunityNameLabelVisible = false;
            this.BasicCommunityNameValue = "";
            this.IsBasicCallSectionVisible = false;
            this.BasicPhoneValue = "";
			this.IsBasicEmailSectionVisible = false;
			this.BasicEmailValue = "";
            this.IsBasicUrlSectionVisible = false;
            this.BasicWebsiteValue = "";
            this.IsBasicLandNumberLabelVisible = false;
            this.BasicLandNumberValue = "";

            //Search detail section for makani related data
            this.IsMakaniInfoSectionVisible = false;
            this.MakaniPlateValue = "";
            this.BuildingEntranceNameValue = "";
            this.MakaniAddressValue = "";
            this.IsMakaniStreetLevelSectionVisible = false;
            //this.$refs.StreetLevelMakaniThumbImgSrc.src = "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQgoXO2FDvwxnRNxJsbi0mVraXtPcGoNt-kYVcI62MgC--gYbZB";


            //Zone code result section
            this.IsZoningRegulationSectionVisible = false;
            this.ZoneCodeValue = "";
            this.CoastalDetailValue = "";
            this.MetroDetailValue = "";
            this.HeightValue = "";
            this.LandUseValue = "";
            this.ParkingValue = "";
            this.SetBackValue = "";
            this.RemarkValue = "";

            //Map Long Click info popup section
            this.IsMapLongClickInfoSectionVisible = false;
            this.IsMapclickMakaniPlateVisible = false;
            this.MapLongClickMakaniNumbereValue = "";
            this.MapLongClickTitleValue1 = "";
            this.MapLongClickTitleValue2 = "";
            this.MapLongClickTitleValue3 = "";
            //Map single tap info popup
            this.IsMapSingleTapInfoSectionVisible = false;
            this.isStreetMapTapDivVisible = false;

            global.ShareSequenceNumber = "";

            this.IsBasicStreetSectionVisible = false;
            this.isBasicStreetPreviewVisible = false;

            //set routing to default
            /*
            this.routingsearch_model1_latlong_data = "";
            this.routingsearch_model2_latlong_data = "";
            this.routingsearch_model3_latlong_data = "";
            this.routingsearch_model4_latlong_data = "";
            this.routingsearch_model1 = ""; this.routingsearch_model2 = "";
            this.routingsearch_model3 = ""; this.routingsearch_model4 = "";
            */


        },

        UpdateMapSingleTapPopUpDetailValues: function (jsonData) {
            var _self7 = this;
            if (jsonData.DbSeqNo) {
                _self7.IsMapSingleTapInfoSectionVisible = false;
                _self7.IsMapLongClickInfoSectionVisible = true;
                _self7.IsMapclickMakaniPlateVisible = false;

                global.CurrentSreetLatitude = global.CurrentLongPressLatitude;
                global.CurrentSreetLongitude = global.CurrentLongPressLongitude;

                _self7.SharingURl = _self7.SharingBaseURl + "?latlng=" + global.CurrentSreetLatitude + "," + global.CurrentSreetLongitude;
                this.PrepareForAjaxRequest("GetShareLocationSquenceNumber", "", "", "", "");

                setTimeout(function () {
                    _self7.isStreetMapLongTapDivVisible = true;
                }, 500);

                this.doActionWithSelectedLocationAndFavorites("LabelFavoriteButton", global.favLongLocation, false, true);
                return;
            }
            if (jsonData.LatLng) {
                var latLong = jsonData.LatLng.split(",");
                global.favLat = global.CurrentSreetLatitude = Number(latLong[0]);
                global.favLng = global.CurrentSreetLongitude = Number(latLong[1]);
                this.favorite_buildingname_E = jsonData.BldgNameEn;
                this.favorite_buildingname_A = jsonData.BldgNameAr;
                global.MakaniLatitude = Number(latLong[0]);
                global.MakaniLongitude = Number(latLong[1]);
                this.makaniDirectionIconeShow = true;
                this.PrepareForAjaxRequest("GetShareLocationSquenceNumber", "", "", "", "");
            }
            _self7.IsMapSingleTapInfoSectionVisible = true;
            _self7.IsMapclickMakaniPlateVisible = true;
            _self7.IsMapLongClickInfoSectionVisible = false;
            _self7.MapLongClickMakaniNumbereValue = jsonData.Makani;
            global.MakaniRouteNumber = jsonData.Makani;
            _self7.MapLongClickTitleValue1 = jsonData.CommEn;
            _self7.MapLongClickTitleValue2 = jsonData.EntNameE;

            global.favMakaniNumber = jsonData.Makani;
            global.favMakaniEntrName = jsonData.EntNameE;

            setTimeout(function () {
                if (document.getElementById('StreetIframeMapInDetail'))
                    document.getElementById('StreetIframeMapInDetail').src = global.hostAddress + "/Home/StreetLevelPreview";
            }, 200);

            this.doActionWithSelectedLocationAndFavorites("LabelFavoriteButton", global.favMakaniNumber, true, false);
            //_self7.MapLongClickTitleValue3 = jsonData.EmirateE;
        },
        UpdateMakaniSearchDetailValues: function (jsonData) {
            var _self5 = this;
            _self5.IsMakaniInfoSectionVisible = true;

            //_self5.isStreetPreviewVisisble = true;
            _self5.TapOnMapBlinkingValue = "Tap on any map pin to view entrance details";

            try {
                if (jsonData.EntNameE)
                    _self5.BuildingEntranceNameValue = jsonData.EntNameE;
            } catch (e) {
                _self5.BuildingEntranceNameValue = "";
            }

            try {
                if (jsonData.Makani)
                    _self5.MakaniPlateValue = jsonData.Makani;
            } catch (e) {
                _self5.MakaniPlateValue = "XXXXX XXXXX";
            }
            try {
                if (jsonData.AddressE)
                    _self5.MakaniAddressValue = jsonData.AddressE;
            } catch (e) {
                _self5.MakaniAddressValue = "";
            }
            try {
                if (jsonData.hasOwnProperty("SHAPE")) {
                    if (jsonData.SHAPE) {
                        var latLong = jsonData.SHAPE.split(",");
                        global.CurrentSreetLatitude = Number(latLong[1]);
                        global.CurrentSreetLongitude = Number(latLong[0]);

                        this.SetRoutingLatLongData('routingsearch_model1', latLong);
                        global.user_selected_routing_destination_text = jsonData.Makani;
                        this.routingsearch_model1 = global.user_selected_routing_destination_text;

                        global.MakaniLatitude = global.CurrentSreetLatitude;
                        global.MakaniLongitude = global.CurrentSreetLongitude;
                        global.MakaniRouteNumber = jsonData.Makani;

                        setTimeout(function () {
                            _self5.isStreetPreviewVisisble = true;
                        }, 200);



                    }
                }
            } catch (e) {
                _self5.isStreetPreviewVisisble = false;
            }
            _self5.SharingURl = _self5.SharingBaseURl + "?mkn=" + jsonData.Makani + "&sqn=''";
            _self5.doActionWithSelectedLocationAndFavorites('LabelFavoriteButton', _self5.MakaniPlateValue, true, false);
        },

        SetRoutingLatLongData: function (RoutingSearchModelName, locationVar, fromDraggableMarker) {
            switch (RoutingSearchModelName) {
                case "routingsearch_model0":
                    this.routingsearch_model0_latlong_data = locationVar[1] + "," + locationVar[0];
                    if (fromDraggableMarker)
                        this.routingsearch_model0 = locationVar[0] + "," + locationVar[1];
                    break;
                case "routingsearch_model1":
                    this.routingsearch_model1_latlong_data = locationVar[1] + "," + locationVar[0];
                    if (fromDraggableMarker)
                        this.routingsearch_model1 = locationVar[0] + "," + locationVar[1];
                    break;
                case "routingsearch_model2":
                    this.routingsearch_model2_latlong_data = locationVar[1] + "," + locationVar[0];
                    if (fromDraggableMarker)
                        this.routingsearch_model2 = locationVar[0] + "," + locationVar[1];
                    break;
                case "routingsearch_model3":
                    this.routingsearch_model3_latlong_data = locationVar[1] + "," + locationVar[0];
                    if (fromDraggableMarker)
                        this.routingsearch_model3 = locationVar[0] + "," + locationVar[1];
                    break;
                case "routingsearch_model4":
                    this.routingsearch_model4_latlong_data = locationVar[1] + "," + locationVar[0];
                    if (fromDraggableMarker)
                        this.routingsearch_model4 = locationVar[0] + "," + locationVar[1];
                    break;

            }

            this.nonEmptycountSearchBox = this.getNonEmpltyCountRouteSearchBox();
        },
        checkMapTabEnable: function () {
            if (this.IsRoutingDivVisible)
                return this.getEmptyCountRouteSearchBox() > 0;
            else {
                return true;//global.IsMapTapEnable;
            }

        },
        NavigateToDMHeadOffice: function () {
            var dmpositionData = '{"BuildingInfo\":{"Enterance": [{ "Makani":"29971 95280", "EntrenceId":"589", "EntType":"", "RoadNameEn":"Baniyas St.", "RoadNameAr":"شارع بني ياس", "CommEn":"AL RIGGA - 119 , DUBAI", "CommAr":"الرقة - 119 ، دبي", "EmirateA":"دبي", "EmirateE":"DUBAI", "BuildingNo":"20", "Picture":"", "EntNameA":"", "EntNameE":"", "BldgNameEn":"Dubai Municipality- Main Office", "BldgNameAr":"بلدية دبي - المبنى الرئيسي", "BldgPicture":"", "Dltm":"497807.65796774474 2795329.1939557577", "LatLng":"25.2642733870032,55.311569462", "TelNo":"", "Url":"", "FaxNo":"", "PoBox":"", "Email":""}, { "Makani":"30016 95350", "EntrenceId":"590", "EntType":"2", "RoadNameEn":"", "RoadNameAr":"", "CommEn":"AL RIGGA - 119 , DUBAI", "CommAr":"الرقة - 119 ، دبي", "EmirateA":"دبي", "EmirateE":"DUBAI", "BuildingNo":" ", "Picture":"", "EntNameA":"", "EntNameE":"", "BldgNameEn":"Dubai Municipality- Main Office", "BldgNameAr":"بلدية دبي - المبنى الرئيسي", "BldgPicture":"", "Dltm":"497851.5662542319 2795399.185580919", "LatLng":"25.2649052760032,55.3120052389999", "TelNo":"", "Url":"", "FaxNo":"", "PoBox":"", "Email":""}, { "Makani":"30032 95320", "EntrenceId":"591", "EntType":"2", "RoadNameEn":"", "RoadNameAr":"", "CommEn":"AL RIGGA - 119 , DUBAI", "CommAr":"الرقة - 119 ، دبي", "EmirateA":"دبي", "EmirateE":"DUBAI", "BuildingNo":" ", "Picture":"", "EntNameA":"", "EntNameE":"", "BldgNameEn":"Dubai Municipality- Main Office", "BldgNameAr":"بلدية دبي - المبنى الرئيسي", "BldgPicture":"", "Dltm":"497867.98602113035 2795369.5049774786", "LatLng":"25.2646373680032,55.312168289", "TelNo":"", "Url":"", "FaxNo":"", "PoBox":"", "Email":""}, { "Makani":"29969 95333", "EntrenceId":"592", "EntType":"2", "RoadNameEn":"", "RoadNameAr":"", "CommEn":"AL RIGGA - 119 , DUBAI", "CommAr":"الرقة - 119 ، دبي", "EmirateA":"دبي", "EmirateE":"DUBAI", "BuildingNo":" ", "Picture":"", "EntNameA":"", "EntNameE":"", "BldgNameEn":"Dubai Municipality- Main Office", "BldgNameAr":"بلدية دبي - المبنى الرئيسي", "BldgPicture":"", "Dltm":"497804.96100262657 2795381.7100412329", "LatLng":"25.2647474540032,55.311542604", "TelNo":"", "Url":"", "FaxNo":"", "PoBox":"", "Email":""}, { "Makani":"30005 95279", "EntrenceId":"593", "EntType":"", "RoadNameEn":"", "RoadNameAr":"", "CommEn":"AL RIGGA - 119 , DUBAI", "CommAr":"الرقة - 119 ، دبي", "EmirateA":"دبي", "EmirateE":"DUBAI", "BuildingNo":" ", "Picture":"", "EntNameA":"", "EntNameE":"", "BldgNameEn":"Dubai Municipality- Main Office", "BldgNameAr":"بلدية دبي - المبنى الرئيسي", "BldgPicture":"", "Dltm":"497841.29297492839 2795328.7179647069", "LatLng":"25.2642691390032,55.3119033649999", "TelNo":"", "Url":"", "FaxNo":"", "PoBox":"", "Email":""}, { "Makani":"30018 95329", "EntrenceId":"594", "EntType":"2", "RoadNameEn":"", "RoadNameAr":"", "CommEn":"AL RIGGA - 119 , DUBAI", "CommAr":"الرقة - 119 ، دبي", "EmirateA":"دبي", "EmirateE":"DUBAI", "BuildingNo":" ", "Picture":"", "EntNameA":"", "EntNameE":"", "BldgNameEn":"Dubai Municipality- Main Office", "BldgNameAr":"بلدية دبي - المبنى الرئيسي", "BldgPicture":"", "Dltm":"497853.54503386887 2795378.8079755111", "LatLng":"25.2647213270032,55.312024915", "TelNo":"", "Url":"", "FaxNo":"", "PoBox":"", "Email":""}]}, "EntranceInfo": { "Building": [{ "NameAr": "بلدية دبي - المبنى الرئيسي", "NameEn": "Dubai Municipality- Main Office", "Picture": "", "Bldif": "195639", "Coord": "25.2649705211112,55.3125898922808;25.2646318807061,55.3124288106496;25.264679733694,55.3123018923991;25.2646367074148,55.312281906323;25.2646349108916,55.3122810727436;25.2646351816086,55.3122803877164;25.2646399191554,55.3122683947766;25.264642509013,55.3122618324147;25.2646454147074,55.3122544758176;25.2646636700304,55.3122081917985;25.2646232410475,55.3121706737801;25.2646124973017,55.312160708682;25.2644680542243,55.3120384202109;25.2644727925523,55.3120319766053;25.2644564603747,55.3120177735762;25.2644340686899,55.3120502991151;25.264427459985,55.3120445722517;25.264155816666,55.3118086894426;25.2641451452138,55.3117994193066;25.2641359363458,55.3117914195974;25.2641657288666,55.3117494718552;25.2641743779195,55.3117565583583;25.2641821127495,55.3117466794106;25.264169500106,55.3117350270897;25.2641582120379,55.3117253718923;25.2642775144987,55.3115625234472;25.2642192881663,55.3115118246002;25.2642106300084,55.3115042913887;25.2642134549318,55.3115003894864;25.2642208105643,55.3114902425522;25.2642193931126,55.3114889721217;25.2642079898704,55.311475850379;25.26419944788,55.3114603257393;25.2641941644445,55.311443132745;25.2641923834188,55.3114250953102;25.2641942042253,55.3114070473017;25.2641995276965,55.3113898722583;25.2642081011904,55.3113743644014;25.2642195276249,55.3113612782704;25.2642332654599,55.3113512095959;25.2642486467602,55.3113446548596;25.2642649674525,55.3113419120062;25.2642814331678,55.3113431201614;25.2642972675617,55.3113482199032;25.2643117303712,55.3113569731129;25.2643823411366,55.3114199884033;25.2644673955925,55.3113025735966;25.2645159137771,55.3113444379549;25.2645457425948,55.3113046143973;25.2645997592747,55.3113529106513;25.264587132822,55.3113699778669;25.2645983370033,55.3113799229561;25.2645991402608,55.3113788506685;25.2646172631403,55.3113543072421;25.2646286440906,55.3113388980964;25.2646379221378,55.311326348376;25.2646437434773,55.3113184551594;25.2646617734204,55.3113366386403;25.2646774115371,55.3113573242259;25.2646903598755,55.311380144661;25.2647004017195,55.3114046731117;25.2647073384046,55.3114304628855;25.2647110434822,55.3114570573494;25.2647114627141,55.3114839502209;25.2647085689466,55.3115106550668;25.2647305528764,55.3115296221331;25.2649028580479,55.3116782920137;25.2648958724918,55.311688270164;25.2648888327853,55.3116983376683;25.264926597991,55.3117298103711;25.2647747466724,55.311939908097;25.2647618043237,55.3119578191492;25.2647260886024,55.3119282223111;25.2646814674571,55.3119912086556;25.2647132920658,55.312018066257;25.2647405035105,55.3120429690062;25.2647461454291,55.3120425907862;25.2647517153423,55.3120436818136;25.2648045820805,55.3120694040705;25.2648432119908,55.3120881995917;25.2651152729381,55.3122175147923;25.2649705211112,55.3125898922808;" }, { "BldgNameAr": "بلدية دبي - المبنى الرئيسي", "BldgNameEn": "Dubai Municipality- Main Office", "BldgPicture": "", "Bldif": "195639", "Coord": "25.2651191142567,55.3121878215948;25.2650150149886,55.312138133714;25.2650416713627,55.3120696605899;25.2648858159439,55.3119962954023;25.2649375222892,55.3118634296013;25.2649453313137,55.311867101321;25.26498426942,55.3117705218752;25.265130808451,55.3118406422486;25.2651527490686,55.3117795051063;25.2652595195815,55.3118291287319;25.2651191142567,55.3121878215948;" }] }, "IsExp": false, "ExpMessage": ""}';
            this.UpdateUIComponentWithJsonData(dmpositionData, "", "MapTapInfoSection", "", "");

        },
        isArray: function (jsonItem) {
            return Object.prototype.toString.call(jsonItem) === '[object Array]';
        },
        FillZoneRegulationDataInUI: function (zoneItem, _self4, position) {

            try {
                if (zoneItem.ZoneCode) {
                    if (position == 1) {
                        _self4.IsZoneCodeVisisble = true;
                        _self4.ZoneCodeValue = zoneItem.ZoneCode;
                    } else if (position == 2) {
                        _self4.IsZoneCodeVisisble2 = true;
                        _self4.ZoneCodeValue2 = zoneItem.ZoneCode;
                    }
                }

            } catch (e) {
                if (position == 1) {
                    _self4.IsZoneCodeVisisble = false;
                    _self4.ZoneCodeValue = "";
                } else if (position == 2) {
                    _self4.IsZoneCodeVisisble2 = false;
                    _self4.ZoneCodeValue2 = "";
                }
            }

            try {
                if (zoneItem.HeightRegEn)
                    if (position == 1) {
                        _self4.IsHeightRegEnVisisble = true;
                        _self4.HeightValue = zoneItem.HeightRegEn;
                    } else if (position == 2) {
                        _self4.IsHeightRegEnVisisble2 = true;
                        _self4.HeightValue2 = zoneItem.HeightRegEn;
                    }
            } catch (e) {
                if (position == 1) {
                    _self4.IsHeightRegEnVisisble = false;
                    _self4.HeightValue = "";
                } else if (position == 2) {
                    _self4.IsHeightRegEnVisisble2 = false;
                    _self4.HeightValue2 = "";
                }
            }

            try {
                if (zoneItem.LanduseRegEn) {
                    if (position == 1) {
                        _self4.IsLanduseRegEnVisisble = true;
                        _self4.LandUseValue = zoneItem.LanduseRegEn;
                    } else if (position == 2) {
                        _self4.IsLanduseRegEnVisisble2 = true;
                        _self4.LandUseValue2 = zoneItem.LanduseRegEn;
                    }
                }
            } catch (e) {
                if (position == 1) {
                    _self4.IsLanduseRegEnVisisble = false;
                    _self4.LandUseValue = "";
                } else if (position == 2) {
                    _self4.IsLanduseRegEnVisisble2 = false;
                    _self4.LandUseValue2 = "";
                }
            }

            try {
                if (zoneItem.ParkingRegEn) {
                    if (position == 1) {
                        _self4.IsParkingRegEnVisisble = true;
                        _self4.ParkingValue = zoneItem.ParkingRegEn;
                    } else if (position == 2) {
                        _self4.IsParkingRegEnVisisble2 = false;
                        _self4.ParkingValue2 = "";
                    }
                }
            } catch (e) {
                if (position == 1) {
                    _self4.IsParkingRegEnVisisble = false;
                    _self4.ParkingValue = "";
                } else if (position == 2) {
                    _self4.IsParkingRegEnVisisble2 = false;
                    _self4.ParkingValue2 = "";
                }
            }

            try {
                if (zoneItem.SetbackRegEn) {
                    if (position == 1) {
                        _self4.IsSetbackRegEnVisisble = true;
                        _self4.SetBackValue = zoneItem.SetbackRegEn;
                    } else if (position == 2) {
                        _self4.IsSetbackRegEnVisisble2 = false;
                        _self4.SetBackValue2 = "";
                    }
                }
            } catch (e) {
                if (position == 1) {
                    _self4.IsSetbackRegEnVisisble = false;
                    _self4.SetBackValue = "";
                } else if (position == 1) {
                    _self4.IsSetbackRegEnVisisble2 = false;
                    _self4.SetBackValue2 = "";
                }
            }

            try {
                if (zoneItem.RemarksRegEn) {
                    if (position == 1) {
                        _self4.IsRemarksRegEnnVisisble = true;
                        _self4.RemarkValue = zoneItem.RemarksRegEn;
                    } else if (position == 2) {
                        _self4.IsRemarksRegEnnVisisble2 = false;
                        _self4.RemarkValue2 = "";
                    }
                }
            } catch (e) {
                if (position == 1) {
                    _self4.IsRemarksRegEnnVisisble = false;
                    _self4.RemarkValue = "";
                } else if (position == 2) {
                    _self4.IsRemarksRegEnnVisisble2 = false;
                    _self4.RemarkValue2 = "";
                }
            }

        },

        onFavouriteEdit: function (item, index) {
            item.isEdit = true;
            this.$forceUpdate();
            setTimeout(function () {
                $('#fav' + index).focus();
            }, 200);

        },

        UpdateUIComponentWithJsonData: function (ResponseData, RequestData, TargetedUIToUpdate, FeatureclassId, RoutingSearchModelName, favItem, longPress) {
            var _self4 = this;
            var jsonData = "";
            switch (TargetedUIToUpdate) {
                case "SaveFavorite":
                    //0) check response has any favorite in it
                    //1)update values gloabl favrite array variable
                    //2)check new favorite list contains 
                    this.fav_saveloading = false;
                    if (!_self4.isNullOrEmpty(ResponseData)) {
                        //  jsonData = JSON.parse(ResponseData);
                        jsonData = JSON.parse(ResponseData);
                        if (jsonData.hasOwnProperty("IsExp")) {
                            if (!jsonData.IsExp) {
                                //alert("Your favorite has been saved successfully.. ");
                                this.user_favorite_data = global.userFavorites = jsonData.Favorites;
                                this.addFavoriteSuccess = true;
                                setTimeout(function () { _self4.addFavoriteSuccess = false; }, 2000)
                                if (favItem)
                                    _self4.doActionWithSelectedLocationAndFavorites("LabelFavoriteButton", favItem.FavType == "MAKANI" ? favItem.FavValue : favItem.Location, favItem.FavType == "MAKANI", favItem.FavType == "LOCATION");
                            } else {

                                //alert("Favorite submission failed");
                                this.addFavoriteError = true;
                                setTimeout(function () { _self4.addFavoriteError = false; }, 2000)
                            }
                        }

                    }
                    break;
                case "DeleteFromFavoritePopup":

                    if (!_self4.isNullOrEmpty(ResponseData)) {
                        jsonData = JSON.parse(ResponseData);
                        if (!jsonData.IsExp) {
                            //iterate json and check location has already added
                            if (jsonData.hasOwnProperty("Favorites")) {
                                this.user_favorite_data = global.userFavorites = jsonData.Favorites;

                                this.dialog_favorite = false;
                                this.dialog_favorite = true;


                                _self4.doActionWithSelectedLocationAndFavorites("LabelFavoriteButton", favItem.FavType == "MAKANI" ? favItem.FavValue : favItem.Location, favItem.FavType == "MAKANI", favItem.FavType == "LOCATION");

                            }


                        } else {
                            //alert("delete failed.!!!");
                            this.deleteFavoriteError = true;
                            setTimeout(function () { _self4.deleteFavoriteError = false; }, 2000)
                        }
                    }
                    break;
                case "DeleteFavorite":
                    var isLocationListedInFavorite = false;
                    if (!_self4.isNullOrEmpty(ResponseData)) {
                        jsonData = JSON.parse(ResponseData);
                        if (!jsonData.IsExp) {
                            //iterate json and check location has already added
                            if (jsonData.hasOwnProperty("Favorites")) {
                                this.user_favorite_data = global.userFavorites = jsonData.Favorites;

                                _self4.doActionWithSelectedLocationAndFavorites("LabelFavoriteButton", favItem.FavType == "MAKANI" ? favItem.FavValue : favItem.Location, favItem.FavType == "MAKANI", favItem.FavType == "LOCATION");

                            }


                        } else {
                            //alert("delete failed.!!!");
                            this.deleteFavoriteError = true;
                            setTimeout(function () { _self4.deleteFavoriteError = false; }, 2000)
                        }
                    }
                    break;
                case "GetFavorite":
                    if (!_self4.isNullOrEmpty(ResponseData)) {
                        jsonData = JSON.parse(ResponseData);
                        if (!jsonData.IsExp) {
                            //iterate and  save to favorite variable
                            if (jsonData.hasOwnProperty("Favorites"))
                                _self4.user_favorite_data = global.userFavorites = jsonData.Favorites;
                            else
                                _self4.user_favorite_data = [];
                        } else {
                            _self4.user_favorite_data = [];
                        }
                    }
                    break;
                case "BuildingAddressDetails":
                    if (!_self4.isNullOrEmpty(ResponseData)) {
                        jsonData = JSON.parse(ResponseData);
                        if (!jsonData.isExp) {
                            this.clearBuildingSearchFields();
                            if (jsonData.hasOwnProperty("Building")) {
                                if (jsonData.Building.length != 0) {
                                    if (jsonData.Building[0].hasOwnProperty("Makani") && jsonData.Building[0].Makani.length != 0) {
                                        var dgsid = jsonData.Building[0].Makani.replace(/\s/g, '');

                                        this.OnSearchItemClick(dgsid, "2", "");


                                    }
                                }

                            }
                        }
                    }
                    break;
                case "QuickSearchBuildingPopOver":
                    if (!_self4.isNullOrEmpty(ResponseData)) {
                        jsonData = JSON.parse(ResponseData);
                        if (!jsonData.isExp) {
                            switch (RoutingSearchModelName) {
                                case "community_search_model":
                                    _self4.community_search_items = jsonData.Community;
                                    break;
                                case "street_search_model":
                                    _self4.isstreet_search_visible = true;
                                    _self4.street_search_items = jsonData.Community;
                                    break;
                                case "building_search_model":
                                    _self4.isbuidling_search_visible = true;
                                    _self4.building_search_items = jsonData.Building;
                                    break;
                            }
                        }
                    }
                    break;
                case "QuickSearchRoutingDetails":
                    /*
                    if (!_self4.isNullOrEmpty(ResponseData)) {
                        jsonData = JSON.parse(ResponseData);
                        if (!jsonData.isExp) {
                            var locationVar = "";
                            switch (FeatureclassId) {
                                case "5": //Land number                                
                                    //get parcel id & compose request model to get zoning regulation
                                    //call getzoningregulation service by passing parcel id
                                    if (jsonData.hasOwnProperty("PARCEL")) {
                                        if (jsonData.PARCEL.length != 0) {
                                            if (jsonData.PARCEL[0].SHAPE.length > 0) {
                                                locationVar = jsonData.PARCEL[0].SHAPE.split(",");
                                                this.SetRoutingLatLongData(RoutingSearchModelName, locationVar);
                                            }
                                        }
                                    }
                                    break;
                                case "1": //POI
                                    //Set POI info
                                    if (jsonData.hasOwnProperty("POI") || jsonData.hasOwnProperty("MAKANI")) {

                                        if (jsonData.hasOwnProperty("POI")) {
                                            if (jsonData.POI.length > 0) {
                                                if (jsonData.POI[0].hasOwnProperty("SHAPE")) {
                                                    if (jsonData.POI[0].SHAPE.length > 0) {
                                                        locationVar = jsonData.POI[0].SHAPE.split(",");
                                                    }
                                                }
                                            }

                                        }


                                        if (jsonData.hasOwnProperty("MAKANI")) {
                                            if (jsonData.MAKANI.length > 0) {
                                                if (jsonData.MAKANI[0].hasOwnProperty("SHAPE")) {
                                                    if (jsonData.MAKANI[0].SHAPE.length > 0) {
                                                        locationVar = jsonData.MAKANI[0].SHAPE.split(",");
                                                    }
                                                }
                                            }

                                        }

                                        this.SetRoutingLatLongData(RoutingSearchModelName, locationVar);

                                    }
                                    break;
                                case "2": //Makani
                                    // _self4.IsQuickSearchDetailDivVisible = true;  //showing div container
                                    //Set initial makani info value
                                    if (jsonData.hasOwnProperty("MAKANI")) {
                                        if (jsonData.MAKANI.length > 0) {
                                            if (jsonData.MAKANI[0].hasOwnProperty("SHAPE")) {
                                                if (jsonData.MAKANI[0].SHAPE.length > 0) {
                                                    locationVar = jsonData.MAKANI[0].SHAPE.split(",");
                                                }
                                            }
                                        }

                                    }

                                    this.SetRoutingLatLongData(RoutingSearchModelName, locationVar)
                                    break;
                                case "3": //building address                                  
                                    if (jsonData.hasOwnProperty("POI") || jsonData.hasOwnProperty("MAKANI") || jsonData.hasOwnProperty("BUILDING")) {

                                        if (jsonData.hasOwnProperty("BUILDING")) {
                                            if (jsonData.BUILDING.length > 0) {
                                                if (jsonData.BUILDING[0].hasOwnProperty("SHAPE")) {
                                                    if (jsonData.BUILDING[0].SHAPE.length > 0) {
                                                        locationVar = jsonData.BUILDING[0].SHAPE.split(",");
                                                    }
                                                }
                                            }

                                        }

                                        if (jsonData.hasOwnProperty("POI")) {
                                            if (jsonData.POI.length > 0) {
                                                if (jsonData.POI[0].hasOwnProperty("SHAPE")) {
                                                    if (jsonData.POI[0].SHAPE.length > 0) {
                                                        locationVar = jsonData.POI[0].SHAPE.split(",");
                                                    }
                                                }
                                            }

                                        }

                                        if (jsonData.hasOwnProperty("MAKANI")) {
                                            if (jsonData.MAKANI.length > 0) {
                                                if (jsonData.MAKANI[0].hasOwnProperty("SHAPE")) {
                                                    if (jsonData.MAKANI[0].SHAPE.length > 0) {
                                                        locationVar = jsonData.MAKANI[0].SHAPE.split(",");
                                                    }
                                                }
                                            }

                                        }
                                        this.SetRoutingLatLongData(RoutingSearchModelName, locationVar);
                                    }

                                    break;
                                case "6": //community
                                    //_self4.IsQuickSearchDetailDiv = true;  //showing div container
                                    if (jsonData.hasOwnProperty("COMMUNITY")) {
                                        if (jsonData.COMMUNITY.length > 0) {
                                            if (jsonData.COMMUNITY[0].hasOwnProperty("SHAPE")) {
                                                if (jsonData.COMMUNITY[0].SHAPE.length > 0) {
                                                    locationVar = jsonData.COMMUNITY[0].SHAPE.split(",");
                                                }
                                            }
                                        }
                                        if (locationVar) {
                                            this.SetRoutingLatLongData(RoutingSearchModelName, locationVar);

                                        }
                                    }
                                    break;
                            }

                            addDraggableMarker(RoutingSearchModelName, locationVar[1], locationVar[0], true);
                            this.calculateRoute();

                        } else {
                            //Set marker in clicking location
                            //No need to set the point here only in map tap event
                            
                            //addDraggableMarker(clickedMapPoint.lat, clickedMapPoint.lng);
                            //_self4.SetRoutingLatLongData('routingsearch_model2', [clickedMapPoint.lng, clickedMapPoint.lat]);
                            //_self4.routingsearch_model = clickedMapPoint.lat + ',' + clickedMapPoint.lng;
                           // _self4.calculateRoute();
                            
                        }

        }
        */

                    if (!_self4.isNullOrEmpty(ResponseData)) {
                        _self4.search_items = [];
                        jsonData = JSON.parse(ResponseData);
                        if (!jsonData.isExp) {
                            _self4.currentRouteSearchBox = RoutingSearchModelName;
                            var routelocationVar = "";
                            var modelTitle = "";

                            if (jsonData.hasOwnProperty("MAKANI")) {
                                if (jsonData.MAKANI.length > 0) {
                                    //_self5.isStreetPreviewVisisble = true;
                                    _self4.TapOnMapBlinkingValue = "Tap on any map pin to view entrance details";

                                    //if (jsonData.EntNameE.length != 0) 
                                    _self4.BuildingEntranceNameValue = jsonData.MAKANI[0].EntNameE;

                                    _self4.MakaniPlateValue = jsonData.MAKANI[0].Makani;
                                    //if (jsonData.AddressE.length != 0)
                                    _self4.MakaniAddressValue = jsonData.MAKANI[0].AddressE;
                                    if (jsonData.MAKANI[0].hasOwnProperty("SHAPE")) {
                                        if (jsonData.MAKANI[0].SHAPE.length > 0) {
                                            routelocationVar = jsonData.MAKANI[0].SHAPE.split(",");
                                            var latLong = jsonData.MAKANI[0].SHAPE.split(",");
                                            global.CurrentSreetLatitude = Number(latLong[1]);
                                            global.CurrentSreetLongitude = Number(latLong[0]);

                                            if (jsonData.MAKANI.length == 1) {
                                                var empty_search_model = RoutingSearchModelName;
                                                if (empty_search_model) {
                                                    this.SetRoutingLatLongData(empty_search_model, [global.CurrentSreetLongitude, global.CurrentSreetLatitude]);
                                                    this[empty_search_model] = FeatureclassId == 5 && jsonData.hasOwnProperty("PARCEL") && jsonData.PARCEL.length > 0 ? jsonData.PARCEL[0].ParcelId : jsonData.MAKANI[0].Makani;

                                                    addDraggableMarker(empty_search_model, global.CurrentSreetLatitude, global.CurrentSreetLongitude, true);

                                                    this.calculateRoute();

                                                    return;
                                                }
                                            }

                                        }

                                    }
                                }
                            }

                            switch (FeatureclassId) {
                                case "5": //Land number                                
                                    //get parcel id & compose request model to get zoning regulation
                                    //call getzoningregulation service by passing parcel id                                   
                                    if (jsonData.hasOwnProperty("PARCEL")) {
                                        if (jsonData.PARCEL.length != 0) {
                                            if (jsonData.PARCEL[0].SHAPE.length > 0) {
                                                routelocationVar = jsonData.PARCEL[0].SHAPE.split(",");
                                            }
                                            global.DrawingJsonData = "";
                                            global.DrawingRequestData = "";
                                            global.DrawingJsonData = jsonData;
                                            global.DrawingRequestData = RequestData;
                                            //draw on map
                                            //DrawShapesOnMap(jsonData, RequestData, "LANDNUMBER");
                                            if (jsonData.PARCEL[0].ParcelId.length != 0) {
                                                DrawShapesOnMap(jsonData, RequestData, "LANDNUMBER", "");
                                                //call service to get zone result 
                                                modelTitle = jsonData.PARCEL[0].ParcelId;
                                                var modelZoningRegulationRequest = {
                                                    InputJson: {
                                                        Landno: jsonData.PARCEL[0].ParcelId,
                                                        UserId: "0",
                                                        Sessionid: ""
                                                    },
                                                    Token: "l4f76613re4junvvbbd4ufki1j!=+=o6JGpy02dppzxKfVibRYfQ==",
                                                    Remarks: "MAKANI PHASE 2"
                                                };
                                                this.PrepareForAjaxRequest("GetZoningRegulation", modelZoningRegulationRequest, "", "");

                                            } else {
                                                //draw on map
                                                DrawShapesOnMap(jsonData, RequestData, "LANDNUMBER", "");
                                            }
                                        }

                                    }
                                    break;
                                case "1": //POI
                                    //Set POI info
                                    if (jsonData.hasOwnProperty("POI") || jsonData.hasOwnProperty("MAKANI")) {
                                        if (jsonData.POI.length != 0) {
                                            if (jsonData.POI[0].hasOwnProperty("SHAPE")) {
                                                if (jsonData.POI[0].SHAPE.length > 0) {
                                                    routelocationVar = jsonData.POI[0].SHAPE.split(",");
                                                }
                                            }

                                            if (jsonData.POI[0].NameE.length != 0) {
                                                modelTitle = jsonData.POI[0].NameE;
                                                _self4.favorite_buildingname_E = jsonData.POI[0].NameE;
                                                _self4.favorite_buildingname_A = jsonData.POI[0].NameA;
                                            } else {
                                                modelTitle = "Community";
                                            }
                                        }

                                        if (jsonData.MAKANI.length != 0) {
                                            if (jsonData.MAKANI[0].hasOwnProperty("SHAPE")) {
                                                if (jsonData.MAKANI[0].SHAPE.length > 0) {
                                                    routelocationVar = jsonData.MAKANI[0].SHAPE.split(",");
                                                }
                                            }

                                        }

                                        //draw on map
                                        DrawShapesOnMap(jsonData, RequestData, "POI", "");
                                    }




                                    break;
                                case "2": //Makani
                                    // _self4.IsQuickSearchDetailDivVisible = true;  //showing div container
                                    //Set initial makani info value
                                    /*
                                    if (jsonData.hasOwnProperty("MAKANI")) {
                                        if (jsonData.MAKANI.length != 0) {

                                            if (jsonData.MAKANI[0].hasOwnProperty("SHAPE")) {
                                                if (jsonData.MAKANI[0].SHAPE.length > 0) {
                                                    routelocationVar = jsonData.MAKANI[0].SHAPE.split(",");
                                                    var latLong = jsonData.MAKANI[0].SHAPE.split(",");
                                                    global.CurrentSreetLatitude = Number(latLong[1]);
                                                    global.CurrentSreetLongitude = Number(latLong[0]);

                                                }
                                            }
                                            //this.routingsearch_model1 = jsonData.MAKANI[0].Makani;
                                            _self4.TapOnMapBlinkingValue = "Tap on any map pin to view Makani details";

                                            if (this.IsRoutingDivVisible) { //Always true
                                                var empty_search_model = this.getEmptyRouteSearchBox();
                                                if (empty_search_model) {
                                                    this.SetRoutingLatLongData(empty_search_model, [global.CurrentSreetLongitude, global.CurrentSreetLatitude]);
                                                    this[empty_search_model] = global.clickedFallbackTitle;

                                                    addDraggableMarker(empty_search_model, global.CurrentSreetLatitude, global.CurrentSreetLongitude, true);

                                                    this.calculateRoute();
                                                }
                                            }
                                        }
                                    }
                                    */
                                    break;
                                case "3": //building address                                  
                                    if (jsonData.hasOwnProperty("POI") || jsonData.hasOwnProperty("MAKANI") || jsonData.hasOwnProperty("BUILDING")) {
                                        _self4.favorite_buildingname_E = "Building";
                                        _self4.favorite_buildingname_A = "Building";
                                        if (jsonData.hasOwnProperty("POI")) {
                                            if (jsonData.POI.length != 0) {
                                                if (jsonData.POI[0].hasOwnProperty("SHAPE")) {
                                                    if (jsonData.POI[0].SHAPE.length > 0) {
                                                        routelocationVar = jsonData.POI[0].SHAPE.split(",");
                                                    }
                                                }
                                                if (jsonData.POI[0].NameE.length != 0) {
                                                    modelTitle = jsonData.POI[0].NameE;
                                                    _self4.favorite_buildingname_E = jsonData.POI[0].NameE;
                                                    _self4.favorite_buildingname_A = jsonData.POI[0].NameA;
                                                } else if (jsonData.hasOwnProperty("Building")) {
                                                    if (jsonData.BUILDING[0].SHAPE.length > 0) {
                                                        routelocationVar = jsonData.BUILDING[0].SHAPE.split(",");
                                                    }
                                                    if (jsonData.Building[0].BldgNameEn.length != 0) {
                                                        modelTitle = jsonData.Building[0].NameE;
                                                        _self4.favorite_buildingname_E = jsonData.Building[0].NameE;
                                                        _self4.favorite_buildingname_A = jsonData.Building[0].NameA;
                                                    }
                                                }

                                            } else if (jsonData.hasOwnProperty("BUILDING")) {
                                                if (jsonData.BUILDING[0].SHAPE.length > 0) {
                                                    routelocationVar = jsonData.BUILDING[0].SHAPE.split(",");
                                                }
                                            }
                                        }
                                    }

                                    //draw on map
                                    DrawShapesOnMap(jsonData, RequestData, "BUILDINGADDRESS", "");


                                    break;
                                case "6": //community
                                    //_self4.IsQuickSearchDetailDiv = true;  //showing div container
                                    if (jsonData.hasOwnProperty("COMMUNITY")) {
                                        if (jsonData.COMMUNITY.length != 0) {
                                            if (jsonData.COMMUNITY[0].hasOwnProperty("SHAPE")) {
                                                if (jsonData.COMMUNITY[0].SHAPE.length > 0) {
                                                    routelocationVar = jsonData.COMMUNITY[0].SHAPE.split(",");
                                                }
                                            }

                                            _self4.TapOnMapBlinkingValue = "This is a community area";
                                            if (jsonData.COMMUNITY[0].CommunityE.length != 0) {
                                                modelTitle = jsonData.COMMUNITY[0].CommunityE;
                                                _self4.favorite_buildingname_E = jsonData.COMMUNITY[0].CommunityE;
                                                _self4.favorite_buildingname_A = jsonData.COMMUNITY[0].CommunityA;
                                            }

                                            //draw on map
                                            DrawShapesOnMap(jsonData, RequestData, "COMMUNITY", "");
                                        }
                                    }
                                    break;
                                //Fall-back here search details
                                case "10":
                                    routelocationVar = [global.CurrentSreetLongitude, global.CurrentSreetLatitude];
                                    modelTitle = global.clickedFallbackTitle;
                                    DrawShapesOnMap(jsonData, RequestData, "FallBackMarkerDraw", "");
                                    break;
                            }


                            if ((!jsonData.MAKANI || jsonData.MAKANI.length == 0) && routelocationVar) {
                                var empty_search_model = RoutingSearchModelName;
                                if (empty_search_model) {
                                    this.SetRoutingLatLongData(empty_search_model, routelocationVar);
                                    this[empty_search_model] = modelTitle;

                                    addDraggableMarker(empty_search_model, routelocationVar[1], routelocationVar[0], true);

                                    this.calculateRoute();
                                }
                            }

                        }


                    }

                    break;
                //this is to update required data for  search suggestion popover in multi route section
                case "QuickSearchRoutingPopOver":
                    if (!_self4.isNullOrEmpty(ResponseData)) {
                        jsonData = JSON.parse(ResponseData);
                        if (!jsonData.isExp) {
                            switch (RoutingSearchModelName) {
                                case "routingsearch_model0":
                                    _self4.search_routing_items0 = jsonData.LEVEL1.AUTOFILL;
                                    break;
                                case "routingsearch_model1":
                                    _self4.search_routing_items1 = jsonData.LEVEL1.AUTOFILL;
                                    break;
                                case "routingsearch_model2":
                                    _self4.search_routing_items2 = jsonData.LEVEL1.AUTOFILL;
                                    break;
                                case "routingsearch_model3":
                                    _self4.search_routing_items3 = jsonData.LEVEL1.AUTOFILL;
                                    break;
                                case "routingsearch_model4":
                                    _self4.search_routing_items4 = jsonData.LEVEL1.AUTOFILL;
                                    break;
                            }

                        }
                    }
                    break;
                //this is to update required data for search suggestion popover
                case "QuickSearchPopOver":
                    if (!_self4.isNullOrEmpty(ResponseData)) {
                        jsonData = JSON.parse(ResponseData);
                        _self4.search_items = [];

                        if (jsonData.IsExp === false) {

                            this.search_items = jsonData.LEVEL1.AUTOFILL;
                            _self4.forceRerender();
                            this.$refs.searchBox.isMenuActive = true;
                            sendEventToGoogleAnalytics("Smart Search", "Search click", "English");
                        }
                    }
                    break;
                //display wherever you required to show ajax request error message
                case "ErrorOnQuickSearchPopOver":
                    //here data is exception so get data.status & data.responseText
                    break;
                case "QuickSearchDetailDiv":

                    if (!_self4.isNullOrEmpty(ResponseData)) {

                        this.SharingURl = '';

                        _self4.search_items = [];
                        jsonData = JSON.parse(ResponseData);
                        if (!jsonData.isExp) {

                            this.IsMapSingleTapInfoSectionVisible = false;
                            this.IsMapLongClickInfoSectionVisible = false;
                            global.IsMapTapEnable = false;
                            var routelocationVar = "";

                            if (jsonData.hasOwnProperty("MAKANI") && (jsonData.MAKANI && jsonData.MAKANI.length == 1 || (jsonData.MAKANI && jsonData.MAKANI.length == 2 && jsonData.MAKANI[0].Makani == jsonData.MAKANI[1].Makani))) {

                                _self4.IsMakaniInfoSectionVisible = true;
                                //_self5.isStreetPreviewVisisble = true;
                                _self4.TapOnMapBlinkingValue = "Tap on any map pin to view entrance details";


                                //if (jsonData.EntNameE.length != 0) 
                                _self4.BuildingEntranceNameValue = jsonData.MAKANI[0].EntNameE;

                                _self4.MakaniPlateValue = jsonData.MAKANI[0].Makani;
                                //if (jsonData.AddressE.length != 0)
                                _self4.MakaniAddressValue = jsonData.MAKANI[0].AddressE;
                                if (jsonData.MAKANI[0].hasOwnProperty("SHAPE")) {
                                    if (jsonData.MAKANI[0].SHAPE.length > 0) {
                                        routelocationVar = jsonData.MAKANI[0].SHAPE.split(",");
                                        var latLong = jsonData.MAKANI[0].SHAPE.split(",");
                                        global.CurrentSreetLatitude = Number(latLong[1]);
                                        global.CurrentSreetLongitude = Number(latLong[0]);
                                        _self4.isStreetPreviewVisisble = false;
                                        setTimeout(function () {
                                            _self4.isStreetPreviewVisisble = true;
                                            $('#MakaniPlateValueId').find('.v-image__image.v-image__image--cover').css('z-index', '-1');
                                            $('#MapLongClickMakaniNumbereValueId').find('.v-image__image.v-image__image--cover').css('z-index', '-1');
                                        }, 500);
                                        
                                    }

                                }

                                _self4.doActionWithSelectedLocationAndFavorites('LabelFavoriteButton', _self4.MakaniPlateValue, true, false);
                            }

                            switch (FeatureclassId) {
                                case "5": //Land number                                
                                    //get parcel id & compose request model to get zoning regulation
                                    //call getzoningregulation service by passing parcel id                                   
                                    if (jsonData.hasOwnProperty("MAKANI")) {
                                        /*
                                        if (jsonData.MAKANI.length != 0) {
                                            _self4.IsMakaniInfoSectionVisible = true;
                                            //_self5.isStreetPreviewVisisble = true;
                                            _self4.TapOnMapBlinkingValue = "Tap on any map pin to view entrance details";

                                            //if (jsonData.EntNameE.length != 0) 
                                            _self4.BuildingEntranceNameValue = jsonData.MAKANI[0].EntNameE;

                                            _self4.MakaniPlateValue = jsonData.MAKANI[0].Makani;
                                            //if (jsonData.AddressE.length != 0)
                                            _self4.MakaniAddressValue = jsonData.MAKANI[0].AddressE;
                                            if (jsonData.MAKANI[0].hasOwnProperty("SHAPE")) {
                                                if (jsonData.MAKANI[0].SHAPE.length > 0) {
                                                    routelocationVar = jsonData.MAKANI[0].SHAPE.split(",");
                                                    var latLong = jsonData.MAKANI[0].SHAPE.split(",");
                                                    global.CurrentSreetLatitude = Number(latLong[1]);
                                                    global.CurrentSreetLongitude = Number(latLong[0]);
                                                    setTimeout(function () {
                                                        _self4.isStreetPreviewVisisble = true;
                                                    }, 500);
                                                }



                                            }

                                        }
                                        */
                                    }
                                    if (jsonData.hasOwnProperty("PARCEL")) {
                                        if (jsonData.PARCEL.length != 0) {
                                            if (jsonData.PARCEL[0].SHAPE.length > 0) {
                                                routelocationVar = jsonData.PARCEL[0].SHAPE.split(",");
                                            }
                                            global.DrawingJsonData = "";
                                            global.DrawingRequestData = "";
                                            global.DrawingJsonData = jsonData;
                                            global.DrawingRequestData = RequestData;
                                            //draw on map
                                            //DrawShapesOnMap(jsonData, RequestData, "LANDNUMBER");
                                            if (jsonData.PARCEL[0].ParcelId.length != 0) {
                                                DrawShapesOnMap(jsonData, RequestData, "LANDNUMBER", "");
                                                //call service to get zone result 
                                                _self4.ClickedLandNumberValue = jsonData.PARCEL[0].ParcelId;
                                                var modelZoningRegulationRequest = {
                                                    InputJson: {
                                                        Landno: jsonData.PARCEL[0].ParcelId,
                                                        UserId: "0",
                                                        Sessionid: ""
                                                    },
                                                    Token: "l4f76613re4junvvbbd4ufki1j!=+=o6JGpy02dppzxKfVibRYfQ==",
                                                    Remarks: "MAKANI PHASE 2"
                                                };
                                                this.PrepareForAjaxRequest("GetZoningRegulation", modelZoningRegulationRequest, "", "");

                                            } else {
                                                //draw on map
                                                DrawShapesOnMap(jsonData, RequestData, "LANDNUMBER", "");
                                            }
                                        }
                                    }
                                    break;
                                case "1": //POI
                                    //Set POI info
                                    if (jsonData.hasOwnProperty("POI") || jsonData.hasOwnProperty("MAKANI")) {
                                        _self4.TapOnMapBlinkingValue = "This is a POI section";
                                        if (jsonData.POI.length != 0 || jsonData.MAKANI.length != 0) {
                                            _self4.IsQuickSearchDetailDivVisible = true;
                                        }
                                        if (jsonData.POI.length != 0) {
                                            if (jsonData.POI[0].hasOwnProperty("SHAPE")) {
                                                if (jsonData.POI[0].SHAPE.length > 0) {
                                                    routelocationVar = jsonData.POI[0].SHAPE.split(",");
                                                }
                                            }
                                            //showing div container                                      
                                            // Set Basic heading 
                                            _self4.IsBasicLocationNameLabelVisible = true;
                                            if (jsonData.POI[0].NameE.length != 0) {
                                                _self4.BasicLocationNameValue = jsonData.POI[0].NameE;
                                                _self4.favorite_buildingname_E = jsonData.POI[0].NameE;
                                                _self4.favorite_buildingname_A = jsonData.POI[0].NameA;
                                            } else {
                                                _self4.BasicLocationNameValue = "Community";
                                                _self4.favorite_buildingname_E = "Community";
                                            }
                                            //Set basic emirate info
                                            if (jsonData.POI[0].EmirateE.length != 0) {
                                                _self4.IsBasicEmirateLabelVisble = true;
                                                _self4.BasicEmirateValue = jsonData.POI[0].EmirateE;
                                            }
                                            //Set basic community name
                                            if (jsonData.POI[0].CommunityE.length != 0) {
                                                _self4.IsBasicCommunityNameLabelVisible = true;
                                                _self4.BasicCommunityNameValue = jsonData.POI[0].CommunityE;
                                            }
                                            //set basic telphone number
                                            if (jsonData.POI[0].TelNo.length != 0) {
                                                _self4.IsBasicCallSectionVisible = true;
                                                _self4.BasicPhoneValue = jsonData.POI[0].TelNo;
                                            }
                                            if (jsonData.POI[0].Email.length != 0) {
                                                _self4.IsBasicEmailSectionVisible = true;
                                                _self4.BasicEmailValue = jsonData.POI[0].Email;
                                            }
                                            //set basic
                                            if (jsonData.POI[0].Url.length != 0) {
                                                _self4.IsBasicUrlSectionVisible = true;
                                                _self4.BasicWebsiteValue = jsonData.POI[0].Url;
                                            }
                                        }

                                        if (jsonData.MAKANI.length != 0) {
                                            if (jsonData.MAKANI[0].hasOwnProperty("SHAPE")) {
                                                if (jsonData.MAKANI[0].SHAPE.length > 0) {
                                                    routelocationVar = jsonData.MAKANI[0].SHAPE.split(",");
                                                }
                                            }

                                        }

                                        //draw on map
                                        DrawShapesOnMap(jsonData, RequestData, "POI", "");
                                    }




                                    break;
                                case "2": //Makani
                                    // _self4.IsQuickSearchDetailDivVisible = true;  //showing div container
                                    //Set initial makani info value
                                    if (jsonData.hasOwnProperty("MAKANI")) {
                                        if (jsonData.MAKANI.length != 0) {

                                            if (jsonData.MAKANI[0].hasOwnProperty("SHAPE")) {
                                                if (jsonData.MAKANI[0].SHAPE.length > 0) {
                                                    routelocationVar = jsonData.MAKANI[0].SHAPE.split(",");
                                                    var latLong = jsonData.MAKANI[0].SHAPE.split(",");
                                                    global.CurrentSreetLatitude = Number(latLong[1]);
                                                    global.CurrentSreetLongitude = Number(latLong[0]);
                                                    _self4.isStreetPreviewVisisble = false;
                                                    setTimeout(function () {
                                                        _self4.isStreetPreviewVisisble = true;
                                                        $('#MakaniPlateValueId').find('.v-image__image.v-image__image--cover').css('z-index', '-1');
                                                        $('#MapLongClickMakaniNumbereValueId').find('.v-image__image.v-image__image--cover').css('z-index', '-1');
                                                    }, 500);
                                                }
                                            }
                                            this.routingsearch_model1 = jsonData.MAKANI[0].Makani;
                                            _self4.TapOnMapBlinkingValue = "Tap on any map pin to view Makani details";
                                            _self4.IsBasicLocationNameLabelVisible = true;
                                            _self4.BasicLocationNameValue = "Makani";
                                            _self4.favorite_buildingname_E = "Makani";
                                            _self4.favorite_buildingname_A = "Makani";
                                            //Set basic emirate info
                                            if (jsonData.MAKANI[0].EmirateE.length != 0) {
                                                _self4.IsBasicEmirateLabelVisble = true;
                                                _self4.BasicEmirateValue = jsonData.MAKANI[0].EmirateE;
                                            }
                                            //Set basic community name
                                            if (jsonData.MAKANI[0].CommEn.length != 0) {
                                                _self4.IsBasicCommunityNameLabelVisible = true;
                                                _self4.BasicCommunityNameValue = jsonData.MAKANI[0].CommEn;
                                            }

                                            _self4.IsQuickSearchDetailDivVisible = true;

                                        }

                                        //draw on map
                                        DrawShapesOnMap(jsonData, RequestData, "MAKANI", "");
                                    }
                                    
                                    break;
                                case "3": //building address                                  
                                    if (jsonData.hasOwnProperty("POI") || jsonData.hasOwnProperty("MAKANI") || jsonData.hasOwnProperty("BUILDING")) {
                                        _self4.IsQuickSearchDetailDivVisible = true;
                                        _self4.IsBasicLocationNameLabelVisible = true;
                                        _self4.IsBasicEmirateLabelVisble = true;
                                        _self4.BasicLocationNameValue = "Building";
                                        _self4.TapOnMapBlinkingValue = "This is a building area";
                                        _self4.favorite_buildingname_E = "Building";
                                        _self4.favorite_buildingname_A = "Building";
                                        if (jsonData.hasOwnProperty("POI")) {
                                            if (jsonData.POI.length != 0) {
                                                if (jsonData.POI[0].hasOwnProperty("SHAPE")) {
                                                    if (jsonData.POI[0].SHAPE.length > 0) {
                                                        routelocationVar = jsonData.POI[0].SHAPE.split(",");
                                                    }
                                                }
                                                if (jsonData.POI[0].NameE.length != 0) {
                                                    _self4.BasicLocationNameValue = jsonData.POI[0].NameE;
                                                    _self4.favorite_buildingname_E = jsonData.POI[0].NameE;
                                                    _self4.favorite_buildingname_A = jsonData.POI[0].NameA;
                                                } else if (jsonData.hasOwnProperty("Building")) {
                                                    if (jsonData.BUILDING[0].SHAPE.length > 0) {
                                                        routelocationVar = jsonData.BUILDING[0].SHAPE.split(",");
                                                    }
                                                    if (jsonData.Building[0].BldgNameEn.length != 0) {
                                                        _self4.BasicLocationNameValue = jsonData.Building[0].NameE;
                                                        _self4.favorite_buildingname_E = jsonData.Building[0].NameE;
                                                        _self4.favorite_buildingname_A = jsonData.Building[0].NameA;
                                                    }
                                                }


                                                if (jsonData.POI[0].EmirateE.length != 0) {
                                                    _self4.BasicEmirateValue = jsonData.POI[0].NameE;
                                                } else if (jsonData.hasOwnProperty("BUILDING")) {
                                                    if (jsonData.BUILDING[0].SHAPE.length > 0) {
                                                        routelocationVar = jsonData.BUILDING[0].SHAPE.split(",");
                                                    }
                                                    if (jsonData.BUILDING[0].EmirateE.length != 0)
                                                        _self4.BasicLocationNameValue = jsonData.BUILDING[0].EmirateE;
                                                }
                                            }
                                        }
                                        if (jsonData.hasOwnProperty("MAKANI")) {
                                            /*
                                            if (jsonData.MAKANI.length != 0) {
                                                if (jsonData.MAKANI[0].hasOwnProperty("SHAPE")) {
                                                    if (jsonData.MAKANI[0].SHAPE.length > 0) {
                                                        routelocationVar = jsonData.MAKANI[0].SHAPE.split(",");
    
                                                        global.CurrentSreetLatitude = Number(routelocationVar[1]);
                                                        global.CurrentSreetLongitude = Number(routelocationVar[0]);
                                                    }
                                                }
                                                */
                                            /*
                                            if (jsonData.MAKANI.length == 1) {
                                                _self4.IsMakaniInfoSectionVisible = true;
                                                _self4.TapOnMapBlinkingValue = "Tap on any map pin to view Makani details";
                                                if (jsonData.MAKANI[0].Makani.length != 0) {
                                                    _self4.MakaniPlateValue = jsonData.MAKANI[0].Makani;
                                                } else {
                                                    _self4.MakaniPlateValue = "XXXXX XXXXX";
                                                }

                                                if (jsonData.MAKANI[0].EntNameE.length != 0)
                                                    _self4.BuildingEntranceNameValue = jsonData.MAKANI[0].EntNameE;

                                                if (jsonData.MAKANI[0].AddressE.length != 0)
                                                    _self4.MakaniAddressValue = jsonData.MAKANI[0].AddressE;

                                                setTimeout(function () {
                                                    _self4.isStreetPreviewVisisble = true;
                                                }, 500);

                                                _self4.SharingURl = _self4.SharingBaseURl + "?mkn=" + jsonData.MAKANI[0].Makani + "&sqn=''";
                                            }

                                        }
                                        */
                                        }

                                        //draw on map
                                        DrawShapesOnMap(jsonData, RequestData, "BUILDINGADDRESS", "");
                                    }

                                    break;
                                case "6": //community
                                    //_self4.IsQuickSearchDetailDiv = true;  //showing div container
                                    if (jsonData.hasOwnProperty("COMMUNITY")) {
                                        if (jsonData.COMMUNITY.length != 0) {
                                            if (jsonData.COMMUNITY[0].hasOwnProperty("SHAPE")) {
                                                if (jsonData.COMMUNITY[0].SHAPE.length > 0) {
                                                    routelocationVar = jsonData.COMMUNITY[0].SHAPE.split(",");
                                                }
                                            }
                                            _self4.IsQuickSearchDetailDivVisible = true;
                                            _self4.IsBasicLocationNameLabelVisible = true;

                                            _self4.BasicLocationNameValue = "Community";
                                            _self4.favorite_buildingname_E = "Community";
                                            _self4.favorite_buildingname_A = "Community";

                                            _self4.TapOnMapBlinkingValue = "This is a community area";
                                            if (jsonData.COMMUNITY[0].CommunityE.length != 0) {
                                                _self4.IsBasicEmirateLabelVisble = true;
                                                _self4.BasicEmirateValue = jsonData.COMMUNITY[0].CommunityE;
                                                _self4.favorite_buildingname_E = jsonData.COMMUNITY[0].CommunityE;
                                                _self4.favorite_buildingname_A = jsonData.COMMUNITY[0].CommunityA;
                                            }

                                            //draw on map
                                            DrawShapesOnMap(jsonData, RequestData, "COMMUNITY", "");
                                        }
                                    }
                                    break;
                                //Fall-back here search details
                                case "10":
                                    _self4.IsQuickSearchDetailDivVisible = true;
                                    _self4.IsBasicLocationNameLabelVisible = true;
                                    _self4.BasicLocationNameValue = global.clickedFallbackTitle;
                                    _self4.IsBasicEmirateLabelVisble = true;
                                    _self4.BasicEmirateValue = global.clickedFallbackEmirate;
                                    _self4.IsBasicStreetSectionVisible = true;
                                    _self4.favorite_buildingname_E = global.clickedFallbackTitle;
                                    _self4.favorite_buildingname_A = global.clickedFallbackTitle;


                                    var routelocationtemp = global.CurrentSreetLongitude + "," + global.CurrentSreetLatitude;
                                    routelocationVar = routelocationtemp.split(",");


                                    this.routingsearch_model1 = global.clickedFallbackTitle;

                                    setTimeout(function () {
                                        _self4.isBasicStreetPreviewVisible = true;
                                    }, 500);
                                    DrawShapesOnMap(jsonData, RequestData, "FallBackMarkerDraw", "");
                                    break;
                            }

                            this.favorite_name_input_value = this.BasicCommunityNameValue;

                            if (_self4.IsQuickSearchDetailDivVisible) {

                                ResizeDetailDIvWidth();
                                //$('#makaniPlatePng').find('.v-image__image.v-image__image--cover').css('z-index', '-1');
                            }

                            if (routelocationVar) {

                                //var empty_routing = 'routingsearch_model0';
                                //if (global.currentDevicelatitude && global.currentDeviceLongitude)
                                empty_routing = 'routingsearch_model1';

                                this.SetRoutingLatLongData(empty_routing, routelocationVar);

                                if (global.user_selected_routing_destination_text)
                                    this[empty_routing] = global.user_selected_routing_destination_text;

                                global.routelocationVar = routelocationVar;


                                if (global.currentDevicelatitude && global.currentDeviceLongitude) {
                                    //this.SetRoutingLatLongData('routingsearch_model0', [global.currentDeviceLongitude, global.currentDevicelatitude]);
                                    this['routingsearch_model0_latlong_data'] = 'current';
                                    this.routingsearch_model0 = 'Your location';
                                    addDraggableMarker("", global.currentDevicelatitude, global.currentDeviceLongitude, true, true, false, false);
                                }

                                this.SharingURl = this.SharingBaseURl + "?latlng=" + global.CurrentSreetLatitude + "," + global.CurrentSreetLongitude;
                            }
                        }
                                                
                    }

                    break;
                case "LandNumberSearchDetails":
                    //_self4.IsQuickSearchDetailDiv = true;  //showing div container
                    //show landnumber and zoning regulation detail section here
                    if (!_self4.isNullOrEmpty(ResponseData)) {
                        jsonData = JSON.parse(ResponseData);
                        if (!jsonData.isExp) {
                            if (!this.IsRoutingDivVisible) {
                                _self4.TapOnMapBlinkingValue = "This is a land area";
                                _self4.IsQuickSearchDetailDivVisible = true;
                                // Set Basic heading 
                                _self4.IsBasicLocationNameLabelVisible = true;
                                _self4.BasicLocationNameValue = "Parcel Id";
                                //Set basic emirate info

                                _self4.IsBasicEmirateLabelVisble = true;
                                _self4.BasicEmirateValue = _self4.ClickedLandNumberValue;
                            }
                            if (jsonData.hasOwnProperty("Zoningregulations")) {
                                var zoneItems = [];
                                if (this.isArray(jsonData.Zoningregulations.Regulation)) {

                                    for (var i in jsonData.Zoningregulations.Regulation) {
                                        zoneItems[i] = jsonData.Zoningregulations.Regulation[i]
                                        if (i >= 1)
                                            break;
                                    }
                                } else {
                                    zoneItems[0] = jsonData.Zoningregulations.Regulation;
                                }
                                if (!this.IsRoutingDivVisible) {
                                    _self4.IsZoningRegulationSectionVisible = true;
                                    _self4.IsZoneCodeVisisble = false; _self4.IsDescVisisble = false; _self4.IsHeightRegEnVisisble = false;
                                    _self4.IsLanduseRegEnVisisble = false; _self4.IsParkingRegEnVisisble = false;
                                    _self4.IsSetbackRegEnVisisble = false; _self4.IsRemarksRegEnnVisisble = false;
                                    _self4.IsMetroDescVisible = false;

                                    _self4.IsZoneCodeVisisble2 = false; _self4.IsDescVisisble2 = false; _self4.IsHeightRegEnVisisble2 = false;
                                    _self4.IsLanduseRegEnVisisble2 = false; _self4.IsParkingRegEnVisisble2 = false;
                                    _self4.IsSetbackRegEnVisisble2 = false; _self4.IsRemarksRegEnnVisisble2 = false;
                                    _self4.IsMetroDescVisible2 = false;


                                    this.FillZoneRegulationDataInUI(zoneItems[0], _self4, 1);
                                    if (zoneItems.length > 1) {
                                        this.FillZoneRegulationDataInUI(zoneItems[1], _self4, 2);
                                    }

                                }

                                //paste here
                                if (!this.IsRoutingDivVisible) {
                                    try {
                                        if (jsonData.Coastaldetails.Coastaldetail.Desc) {
                                            _self4.IsDescVisisble = true;
                                            _self4.CoastalDetailValue = jsonData.Coastaldetails.Coastaldetail.Desc;
                                        }
                                    } catch (e) {
                                        _self4.IsDescVisisble = false;
                                        _self4.CoastalDetailValue = "";
                                    }


                                    try {
                                        if (jsonData.Metrodetails.Metrodetail.Desc) {
                                            _self4.IsMetroDescVisible = true;
                                            _self4.MetroDetailValue = jsonData.Metrodetails.Metrodetail.Desc;
                                        }
                                    } catch (e) {
                                        _self4.IsMetroDescVisible = false;
                                        _self4.MetroDetailValue = "";
                                    }
                                }

                                if (global.DrawingJsonData.MAKANI.length > 0 || !this.IsRoutingDivVisible) {
                                    try {

                                        if (zoneItems[0].Color) {
                                            DrawShapesOnMap(global.DrawingJsonData, global.DrawingRequestData, "LANDNUMBER", zoneItems[0].Color);
                                        } else {
                                            DrawShapesOnMap(global.DrawingJsonData, global.DrawingRequestData, "LANDNUMBER", "");
                                        }
                                    } catch (e) {
                                        DrawShapesOnMap(global.DrawingJsonData, global.DrawingRequestData, "LANDNUMBER", "");
                                    }
                                }

                            }

                        }
                    }

                    break;
                case "MapTapInfoSection":
                    this.makaniLoading = false;
                    var noReset = true;
                    if (!_self4.isNullOrEmpty(ResponseData)) {
                        jsonData = JSON.parse(ResponseData);
                        if (!jsonData.isExp) {
                            //this.OnToolSearchCloseClick();

                            this.IsMapLongClickInfoSectionVisible = false;
                            this.IsMapSingleTapInfoSectionVisible = false;
                            this.IsMapclickMakaniPlateVisible = false;

                            if (!_self4.IsRoutingDivVisible)
                                global.IsMapTapEnable = false;
                            if (jsonData.hasOwnProperty("BuildingInfo")) {
                                if (jsonData.BuildingInfo.length !== 0) {

                                    _self4.TSearchClear = true;
                                    _self4.TSearchDirection = false;
                                    //show makani plate on map and close, create  
                                    _self4.ResetSearchUIPopOverValuesToDefault();
                                    _self4.MapLongClickMakaniNumbereValue = jsonData.BuildingInfo.Enterance[0].Makani;
                                    _self4.MapLongClickTitleValue1 = jsonData.BuildingInfo.Enterance[0].CommEn;

                                    _self4.MapLongClickTitleValue2 = jsonData.BuildingInfo.Enterance[0].EntNameE;
                                    // _self4.MapLongClickTitleValue3 = jsonData.BuildingInfo.Enterance[0].EmirateE;

                                    if (jsonData.BuildingInfo.Enterance[0].hasOwnProperty("LatLng")) {
                                        if (jsonData.BuildingInfo.Enterance[0].LatLng) {
                                            var latLong = jsonData.BuildingInfo.Enterance[0].LatLng.split(",");
                                            global.favLat = global.CurrentSreetLatitude = Number(latLong[0]);
                                            global.favLng = global.CurrentSreetLongitude = Number(latLong[1]);
                                            var locationarray = [global.CurrentSreetLongitude, global.CurrentSreetLatitude];

                                            global.MakaniLatitude = Number(latLong[0]);
                                            global.MakaniLongitude = Number(latLong[1]);
                                            global.MakaniRouteNumber = global.favMakaniNumber = jsonData.BuildingInfo.Enterance[0].Makani;

                                            this.favorite_buildingname_E = jsonData.BuildingInfo.Enterance[0].BldgNameEn;
                                            this.favorite_buildingname_A = jsonData.BuildingInfo.Enterance[0].BldgNameAr;
                                            //this.makaniDirectionIconeShow = true;

                                            this.doActionWithSelectedLocationAndFavorites('LabelFavoriteButton', global.favMakaniNumber, true, false);

                                            /*
                                            var empty_search_model = this.getEmptyRouteSearchBox();
                                            if (empty_search_model) {
                                                this.SetRoutingLatLongData(empty_search_model, locationarray);
                                                if (jsonData.BuildingInfo.Enterance[0].Makani) {
                                                    this[empty_search_model] = jsonData.BuildingInfo.Enterance[0].Makani;
                                                } else {
                                                    this[empty_search_model] = global.CurrentSreetLatitude + "," + global.CurrentSreetLongitude;
                                                }
                                            }
                                            */


                                            //_self4.SetRoutingLatLongData('routingsearch_model0', [global.currentDeviceLongitude,global.currentDevicelatitude]);
                                            //_self4.routingsearch_model0 = 'Your location';

                                            this.PrepareForAjaxRequest("GetShareLocationSquenceNumber", "", "", "", "");

                                            if (!_self4.IsRoutingDivVisible) {
                                                _self4.IsMapSingleTapInfoSectionVisible = false;
                                                _self4.IsMapclickMakaniPlateVisible = false;

                                                setTimeout(function () {
                                                    _self4.isStreetMapTapDivVisible = true;
                                                }, 500);
                                            } else {

                                                if (jsonData.BuildingInfo.Enterance.length == 1) {
                                                    _self4.IsMapSingleTapInfoSectionVisible = false;
                                                    _self4.IsMapclickMakaniPlateVisible = false;
                                                    this.nonEmptycountSearchBox = this.getNonEmpltyCountRouteSearchBox();

                                                    var empty_search_model = this.getEmptyRouteSearchBox();
                                                    if (empty_search_model) {
                                                        this.SetRoutingLatLongData(empty_search_model, [global.MakaniLongitude, global.MakaniLatitude]);
                                                        if (global.MakaniRouteNumber)
                                                            this[empty_search_model] = global.MakaniRouteNumber;

                                                        addDraggableMarker(empty_search_model, global.MakaniLatitude, global.MakaniLongitude, true);

                                                        this.IsMapSingleTapInfoSectionVisible = false;
                                                        this.IsMapclickMakaniPlateVisible = false;
                                                        this.calculateRoute();
                                                    }
                                                    return;
                                                } else {
                                                    _self4.IsMapSingleTapInfoSectionVisible = false;
                                                    _self4.IsMapclickMakaniPlateVisible = false;
                                                }
                                            }

                                        }
                                    }
                                    _self4.SharingURl = _self4.SharingBaseURl + "?latlng=" + global.CurrentSreetLatitude + "," + global.CurrentSreetLongitude;
                                    DrawShapesOnMap(jsonData, RequestData, "MapLongClickInfoSection", "");

                                    noReset = true;
                                }
                            }
                        } else {
                            if (!longPress)
                                _self4.snackbar_no_result_found = true;
                            else
                                removeAllMapObjects();
                        }
                    } else {
                        if (!_self4.IsRoutingDivVisible) {
                            if (!longPress) {
                                _self4.snackbar_no_result_found = true;
                                _self4.snackbar_no_result_found_text = "Sorry, Makani can't find any data on clicked location";
                            } else
                                removeAllMapObjects();

                        } else {
                            if (clickedMapPoint) {
                                this.IsMapSingleTapInfoSectionVisible = false;
                                this.IsMapclickMakaniPlateVisible = false;

                                //Update the empty destination
                                var empty_search_model = _self4.getEmptyRouteSearchBox();
                                if (empty_search_model) {
                                    addDraggableMarker(empty_search_model, clickedMapPoint.lat(), clickedMapPoint.lng());

                                    _self4.SetRoutingLatLongData(empty_search_model, [clickedMapPoint.lng(), clickedMapPoint.lat()]);
                                    _self4[empty_search_model] = "Map Point";//clickedMapPoint.lat + "," + clickedMapPoint.lng
                                    this.nonEmptycountSearchBox = this.getNonEmpltyCountRouteSearchBox();
                                    _self4.calculateRoute();
                                }
                            }
                        }
                    }

                    if (longPress) {
                        var modelShareLocation = {
                            InputJson: {
                                Name: "queryy",
                                Latitude: clickedMapPoint.lat(),
                                Longitude: clickedMapPoint.lng(),
                                UserId: "0",
                                sessionid: ""
                            },
                            Token: "l4f76613re4junvvbbd4ufki1j!=+=o6JGpy02dppzxKfVibRYfQ==",
                            Remarks: "MAKANI PHASE 2"
                        };

                        this.PrepareForAjaxRequest("GetMapLongPressLocationInfo", modelShareLocation, "", "", "");
                    }

                    break;
                case "MapLongClickInfoSection":

                    this.makaniLoading = false;
                    if (!_self4.isNullOrEmpty(ResponseData)) {
                        jsonData = JSON.parse(ResponseData);
                        if (!jsonData.isExp) {

                            global.IsMapTapEnable = true;
                            this.search_model = "";
                            this.ToolbarSearchDetailProgress = false;
                            this.TSearchClear = false;
                            this.TSearchDirection = true;
                            this.ResetSearchUIPopOverValuesToDefault();
                            this.TSearchMicOn = false;
                            this.$nextTick(function () {
                                this.selected = null;
                            });

                            global.IsMapTapEnable = true;
                            if (jsonData.hasOwnProperty("DbSeqNo")) {
                                if (jsonData.DbSeqNo.length != 0) {
                                    //show share location info
                                    //set sharing link here with Dbseqno 
                                    //eg: http://makanai/home?lc="Dbseqno"
                                    _self4.TSearchClear = true;
                                    _self4.TSearchDirection = false;
                                    _self4.ResetSearchUIPopOverValuesToDefault();
                                    _self4.IsMapLongClickInfoSectionVisible = true;
                                    _self4.IsMapclickMakaniPlateVisible = false;
                                    _self4.MapLongClickTitleValue1 = global.mapPointTitle = jsonData.CommunityE;
                                    var jsonStr = JSON.stringify(RequestData);
                                    var jsonRequestData = JSON.parse(jsonStr);
                                    // _self4.MapLongClickTitleValue2 = jsonRequestData.InputJson.Latitude;
                                    // _self4.MapLongClickTitleValue3 = jsonRequestData.InputJson.Longitude;
                                    _self4.MapLongClickTitleValue2 = "";
                                    _self4.MapLongClickTitleValue3 = "";
                                    global.CurrentSreetLatitude = global.CurrentLongPressLatitude = Number(jsonRequestData.InputJson.Latitude);
                                    global.CurrentSreetLongitude = global.CurrentLongPressLongitude = Number(jsonRequestData.InputJson.Longitude);

                                    var locationarray1 = [global.CurrentSreetLongitude, global.CurrentSreetLatitude];


                                    global.favLocationLat = global.CurrentLongPressLatitude;
                                    global.favLocationLng = global.CurrentLongPressLongitude;
                                    this.favorite_buildingname_E = jsonData.CommunityE;
                                    this.favorite_buildingname_A = jsonData.CommunityA;
                                    global.favSeqNo = jsonData.DbSeqNo;


                                    global.favLongLocation = global.favLocationLat + "," + global.favLocationLng;

                                    this.doActionWithSelectedLocationAndFavorites('LabelFavoriteButton', global.favLongLocation, false, true);

                                    if (this.IsRoutingDivVisible) {
                                        _self4.IsMapLongClickInfoSectionVisible = false;
                                        _self4.IsMapclickMakaniPlateVisible = false;

                                        var empty_search_model = _self4.getEmptyRouteSearchBox();
                                        if (empty_search_model) {
                                            addDraggableMarker(empty_search_model, global.CurrentSreetLatitude, global.CurrentSreetLongitude, true);
                                            _self4.SetRoutingLatLongData(empty_search_model, locationarray1);
                                            _self4[empty_search_model] = "Map point -" + jsonData.CommunityE;
                                            _self4.nonEmptycountSearchBox = _self4.getNonEmpltyCountRouteSearchBox();
                                            _self4.calculateRoute();
                                        }

                                        //_self4.SetRoutingLatLongData('routingsearch_model0', [global.currentDeviceLongitude,global.currentDevicelatitude]);
                                        //self4.routingsearch_model0 = 'Your location';
                                    } else {

                                        this.PrepareForAjaxRequest("GetShareLocationSquenceNumber", "", "", "", "");
                                        setTimeout(function () {
                                            _self4.isStreetMapLongTapDivVisible = true;
                                        }, 500);
                                        _self4.SharingURl = _self4.SharingBaseURl + "?latlng=" + global.CurrentSreetLatitude + "," + global.CurrentSreetLongitude;

                                        DrawShapesOnMap(jsonData, jsonRequestData, "MapLongClickInfoSection", "", true);
                                    }
                                }
                            }
                        }
                    } else {
                        _self4.snackbar_no_result_found = true;
                        _self4.snackbar_no_result_found_text = "Oops!!, No data found on map long press";
                    }

                    break;
                case "MakaniShareUrlInfoSection":
                    if (!_self4.isNullOrEmpty(ResponseData)) {
                        jsonData = JSON.parse(ResponseData);
                        if (!jsonData.isExp) {
                            if (jsonData.hasOwnProperty("MAKANI")) {
                                if (jsonData.MAKANI.length != 0) {
                                    _self4.ResetSearchUIPopOverValuesToDefault();

                                    _self4.IsMapLongClickInfoSectionVisible = true;
                                    _self4.IsMapclickMakaniPlateVisible = true;
                                    _self4.MapLongClickMakaniNumbereValue = jsonData.MAKANI[0].Makani;
                                    _self4.MapLongClickTitleValue1 = jsonData.MAKANI[0].CommEn;

                                    _self4.MapLongClickTitleValue2 = jsonData.MAKANI[0].EntNamE;
                                    //_self4.MapLongClickTitleValue3 = jsonData.MAKANI[0].EmirateE;
                                    _self4.SharingURl = _self4.SharingBaseURl + "?mkn=" + jsonData.MAKANI[0].Makani + "&sqn=''";
                                    DrawShapesOnMap(jsonData, RequestData, "MakaniMapShareUrlMapSection", "");
                                }

                            }
                        }
                    }
                    break;
                case "GetLocation":
                    if (!_self4.isNullOrEmpty(ResponseData)) {
                        jsonData = JSON.parse(ResponseData);
                        if (!jsonData.isExp) {
                            DrawShapesOnMap(jsonData, RequestData, "LocationMapShareUrlMapSection", "");
                        }
                    }
                    break;
                case "GetSequenceNumber":
                    if (!_self4.isNullOrEmpty(ResponseData)) {
                        jsonData = JSON.parse(ResponseData);
                        if (!jsonData.isExp) {
                            global.ShareSequenceNumber = "";
                            if (jsonData.hasOwnProperty("DbSeqNo")) {
                                if (jsonData.DbSeqNo.length !== 0) {
                                    global.ShareSequenceNumber = jsonData.DbSeqNo;
                                    //global.favSeqNo = jsonData.DbSeqNo;
                                    //this.doActionWithSelectedLocationAndFavorites('LabelFavoriteButton', global.favLocation, false, true);
                                }

                            }
                        }
                    }

                    break;
                case "VirtualPlate":
                    if (!_self4.isNullOrEmpty(ResponseData)) {
                        jsonData = JSON.parse(ResponseData);
                        _self4.search_items = [];
                        //if (jsonData.IsExp === false) {

                        //    this.search_items = jsonData.LEVEL1.AUTOFILL;
                        //    _self4.forceRerender();
                        //    this.$refs.searchBox.isMenuActive = true;
                        //    sendEventToGoogleAnalytics("Smart Search", "Search click", "English");
                        //}
                        CallStreetViewPanaroma(ResponseData);
                    }
                    break;

            }

            /* 15July2021 - only for mobile web - do not show search details div*/
            if (global.makaniPinWidth == 57) {
                if (!global.IsLoaded) {
                    _self4.IsQuickSearchDetailDivVisible = false;
                    _self4.topArrowToShowDetailDIv = true;
                } else {
                    global.IsLoaded = false;
                }
            }
        },
        DoAjaxServiceRequest: function (RequestUrl, RequestParam, RequestUrl2, RequestParam2, TargetedUItoUpdateData, TargetedErrorUI, ProgressVar, FeatureClassId,
            RoutingSearcModelName, favItem, longPress) {

            var self = this;
            if (RequestParam2) {
                RequestParam = { 'param1': RequestParam, 'param2': RequestParam2 };
            }

            if ((TargetedUItoUpdateData == "QuickSearchPopOver" || TargetedUItoUpdateData == "QuickSearchRoutingPopOver") && lastRequestIsSearch && lastRequest) {
                lastRequest.abort();
            }

            if (TargetedUItoUpdateData == "QuickSearchPopOver" || TargetedUItoUpdateData == "QuickSearchRoutingPopOver")
                lastRequestIsSearch = true;
            else
                lastRequestIsSearch = false;

            lastRequest = $.ajax({
                url: RequestUrl,
                type: "POST",
                crossDomain: true,
                //headers: { "Access-Control-Allow-Origin": "*" },
                headers: { 'Access-Control-Allow-Origin': '*', 'x-my-custom-header': 'DMGIS2023MakaniWebSite' },
                data: JSON.stringify(RequestParam),
                cache: false,
                async: true,
                contentType: "application/json",
                beforeSend: function () {
                    // show loading progress
                    switch (ProgressVar) {
                        case "isFavoriteLoading":
                            self.fav_saveloading = true;
                            break;
                        case "isAutoCompleteLoading":

                            self.isAutoCompleteLoading = true;
                            break;
                        case "ToolbarSearchDetailProgress":
                            self.TSearchMicOn = false;
                            self.TSearchClear = false;
                            self.TSearchDirection = false;
                            self.ToolbarSearchDetailProgress = true;
							self.IsBasicCallSectionVisible = false;
							self.IsBasicEmailSectionVisible = false;
							self.IsBasicUrlSectionVisible = false;
                            break;
                        case "RoutingQuckSearchProgress":
                            switch (RoutingSearcModelName) {
                                case "routingsearch_model0":
                                    self.isRouting0Loading = true;
                                    break;
                                case "routingsearch_model1":
                                    self.isRouting1Loading = true;
                                    break;
                                case "routingsearch_model2":
                                    self.isRouting2Loading = true;
                                    break;
                                case "routingsearch_model3":
                                    self.isRouting3Loading = true;
                                    break;
                                case "routingsearch_model4":
                                    self.isRouting4Loading = true;
                                    break;

                            }
                            break;
                        case "BuildingSearchProgress":
                            switch (RoutingSearcModelName) {
                                case "community_search_model":
                                    self.iscommunity_search_loading = true;
                                    break;
                                case "street_search_model":
                                    self.isstreet_search_loading = true;
                                    break;
                                case "building_search_model":
                                    self.isbuilding_search_loading = true;
                                    break;


                            }
                            break;
                    }
                },
                success: function (data) {
                    switch (ProgressVar) {
                        case "isFavoriteLoading":
                            self.fav_saveloading = false;
                            break;
                        case "isAutoCompleteLoading":
                            self.isAutoCompleteLoading = false;
                            break;
                        case "ToolbarSearchDetailProgress":
                            self.ToolbarSearchDetailProgress = false;
                            self.TSearchDirection = false;
                            self.TSearchClear = true;
                            break;
                        case "RoutingQuckSearchProgress":
                            switch (RoutingSearcModelName) {
                                case "routingsearch_model0":
                                    self.isRouting0Loading = false;
                                    break;
                                case "routingsearch_model1":
                                    self.isRouting1Loading = false;
                                    break;
                                case "routingsearch_model2":
                                    self.isRouting2Loading = false;
                                    break;
                                case "routingsearch_model3":
                                    self.isRouting3Loading = false;
                                    break;
                                case "routingsearch_model4":
                                    self.isRouting4Loading = false;
                                    break;

                            }
                            break;
                        case "BuildingSearchProgress":
                            switch (RoutingSearcModelName) {
                                case "community_search_model":
                                    self.iscommunity_search_loading = false;
                                    break;
                                case "street_search_model":
                                    self.isstreet_search_loading = false;
                                    break;
                                case "building_search_model":
                                    self.isbuilding_search_loading = false;
                                    break;


                            }
                            break;
                        case "VirtualPlate":
                            if (global.IsStreetLevelViewIsAvailable)
                                this.streetFullViewDiv = true;
                            else
                                this.streetFullViewDiv = false;
                            global.modelVirtualPlateResponse = data;
                            break;

                    }
                    if (!self.isNullOrEmpty(TargetedUItoUpdateData)) {
                        self.UpdateUIComponentWithJsonData(data, RequestParam, TargetedUItoUpdateData, FeatureClassId, RoutingSearcModelName, favItem, longPress);
                    }
                },
                Error: function (xhr, status, error) {
                    //return the error
                    //Write error in console

                    switch (ProgressVar) {
                        case "isFavoriteLoading":
                            self.fav_saveloading = false;
                            break;
                        case "isAutoCompleteLoading":
                            self.isAutoCompleteLoading = false;
                            break;
                        case "ToolbarSearchDetailProgress":
                            self.ToolbarSearchDetailProgress = false;
                            self.TSearchDirection = false;
                            self.TSearchClear = true;
                            break;
                        case "RoutingQuckSearchProgress":
                            switch (RoutingSearcModelName) {
                                case "routingsearch_model0":
                                    self.isRouting0Loading = false;
                                    break;
                                case "routingsearch_model1":
                                    self.isRouting1Loading = false;
                                    break;
                                case "routingsearch_model2":
                                    self.isRouting2Loading = false;
                                    break;
                                case "routingsearch_model3":
                                    self.isRouting3Loading = false;
                                    break;
                                case "routingsearch_model4":
                                    self.isRouting4Loading = false;
                                    break;

                            }
                            break;
                        case "BuildingSearchProgress":
                            switch (RoutingSearcModelName) {
                                case "community_search_model":
                                    self.iscommunity_search_loading = false;
                                    break;
                                case "street_search_model":
                                    self.isstreet_search_loading = false;
                                    break;
                                case "building_search_model":
                                    self.isbuilding_search_loading = false;
                                    break;


                            }
                            break;
                    }
                    if (!self.isNullOrEmpty(TargetedErrorUI)) {
                        self.UpdateUIComponentWithJsonData(xhr, RequestParam, TargetedErrorUI, FeatureClassId);
                    }
                },
                complete: function () {
                    switch (ProgressVar) {
                        case "isFavoriteLoading":
                            self.fav_saveloading = false;
                            break;
                        case "isAutoCompleteLoading":
                            self.isAutoCompleteLoading = false;
                            break;
                        case "ToolbarSearchDetailProgress":
                            self.ToolbarSearchDetailProgress = false;
                            self.TSearchDirection = false;
                            self.TSearchClear = true;
                            break;
                        case "RoutingQuckSearchProgress":
                            switch (RoutingSearcModelName) {
                                case "routingsearch_model0":
                                    self.isRouting0Loading = false;
                                    break;
                                case "routingsearch_model1":
                                    self.isRouting1Loading = false;
                                    break;
                                case "routingsearch_model2":
                                    self.isRouting2Loading = false;
                                    break;
                                case "routingsearch_model3":
                                    self.isRouting3Loading = false;
                                    break;
                                case "routingsearch_model4":
                                    self.isRouting4Loading = false;
                                    break;

                            }
                            break;
                        case "BuildingSearchProgress":
                            switch (RoutingSearcModelName) {
                                case "community_search_model":
                                    self.iscommunity_search_loading = false;
                                    break;
                                case "street_search_model":
                                    self.isstreet_search_loading = false;
                                    break;
                                case "building_search_model":
                                    self.isbuilding_search_loading = false;
                                    break;


                            }
                            break;
                    }
                }

            });
        },
        PrepareForAjaxRequest: function (RequestType, Param, Param2, FeatureclassId, RoutingModelName, favItem, longPress) {
            var ServiceUrl = "";
            switch (RequestType) {
                case "DeleteFavorite":
                    var favoriteDeleteUrl = "https://www.makani.ae/MakaniPhase2ProxyWebService/MakaniPhase2Proxy.svc/SyncFavourites";
                    ServiceUrl = global.hostAddress + "/Home/SyncOrGetFavorite?RequestUrl=" + favoriteDeleteUrl;
                    this.DoAjaxServiceRequest(ServiceUrl, Param, "", "", "DeleteFavorite", "", "", "", "", favItem);
                    break;
                case "DeleteFromFavoritePopup":
                    var favoriteDeletepopupUrl = "https://www.makani.ae/MakaniPhase2ProxyWebService/MakaniPhase2Proxy.svc/SyncFavourites";
                    ServiceUrl = global.hostAddress + "/Home/SyncOrGetFavorite?RequestUrl=" + favoriteDeletepopupUrl;
                    this.DoAjaxServiceRequest(ServiceUrl, Param, "", "", "DeleteFromFavoritePopup", "", "", "", "", favItem);
                    break;
                case "SaveFavorite":
                    var saveFavoriteUrl = "https://www.makani.ae/MakaniPhase2ProxyWebService/MakaniPhase2Proxy.svc/SyncFavourites";
                    ServiceUrl = global.hostAddress + "/Home/SyncOrGetFavorite?RequestUrl=" + saveFavoriteUrl;
                    this.currentFavType = Param.FavType;
                    this.currentFavName = Param.FavName;
                    this.DoAjaxServiceRequest(ServiceUrl, Param, "", "", "SaveFavorite", "", "isFavoriteLoading", "", "", favItem);
                    break;
                case "GetFavorite":
                    var getFavorteUrl = "https://www.makani.ae/MakaniPhase2ProxyWebService/MakaniPhase2Proxy.svc/GetFavorites";
                    ServiceUrl = global.hostAddress + "/Home/SyncOrGetFavorite?RequestUrl=" + getFavorteUrl;
                    this.DoAjaxServiceRequest(ServiceUrl, Param, "", "", "GetFavorite", "", "isFavoriteLoading", "", "");
                    break;
                case "QuickSearchCommunity":
                    var getCommunitiesUrl = "https://www.makani.ae/MakaniPhase2ProxyWebService/MakaniPhase2Proxy.svc/GetAllCommunities";
                    ServiceUrl = global.hostAddress + "/Home/GetCommunities?RequestUrl=" + getCommunitiesUrl;
                    this.DoAjaxServiceRequest(ServiceUrl, Param, "", "", "QuickSearchBuildingPopOver", "ErrorQuickSearchCommunityDetails", "BuildingSearchProgress", FeatureclassId, RoutingModelName);
                    break;
                case "QuickSearchStreet":
                    //var getStreetsUrl = "https://www.makani.ae/MakaniPhase2ProxyWebService/MakaniPhase2Proxy.svc/GetStreetsFromCommunity";
                    var getStreetsUrl = "https://www.makani.ae/MakaniPhase2ProxyWebService/MakaniPhase2Proxy.svc/GetStreetsFromCommunity";
                    ServiceUrl = global.hostAddress + "/Home/GetStreets?RequestUrl=" + getStreetsUrl;
                    this.DoAjaxServiceRequest(ServiceUrl, Param, "", "", "QuickSearchBuildingPopOver", "ErrorQuickSearchStreetDetails", "BuildingSearchProgress", FeatureclassId, RoutingModelName);
                    break;
                case "QuickSearchBuildings":
                    var getBuildingsUrl = "https://www.makani.ae/MakaniPhase2ProxyWebService/MakaniPhase2Proxy.svc/GetBuildingsList";
                    ServiceUrl = global.hostAddress + "/Home/GetBuildings?RequestUrl=" + getBuildingsUrl;
                    this.DoAjaxServiceRequest(ServiceUrl, Param, "", "", "QuickSearchBuildingPopOver", "ErrorQuickSearchBuildingDetails", "BuildingSearchProgress", FeatureclassId, RoutingModelName);
                    break;
                case "GetBuildingAddress":
                    var getBuildingAddressUrl = "https://www.makani.ae/MakaniPhase2ProxyWebService/MakaniPhase2Proxy.svc/GetBuildingAddress";
                    ServiceUrl = global.hostAddress + "/Home/GetBuildings?RequestUrl=" + getBuildingAddressUrl;
                    this.DoAjaxServiceRequest(ServiceUrl, Param, "", "", "BuildingAddressDetails", "", "", FeatureclassId, RoutingModelName);
                    break;

                case "QuickSearchRoutingDetail":
                    var smartsearchDetailUrl = "https://www.makani.ae/MakaniPhase2ProxyWebService/MakaniPhase2Proxy.svc/SmartSearchResult";
                    ServiceUrl = global.hostAddress + "/Home/GetQuickSearchDetails?RequestUrl=" + smartsearchDetailUrl;
                    this.DoAjaxServiceRequest(ServiceUrl, Param, "", "", "QuickSearchRoutingDetails", "ErrorQuickSearchRoutingDetails", "RoutingSearchDetailProgress", FeatureclassId, RoutingModelName);
                    break;
                case "QuickSearchRouting":
                    var smartsearchUrl = "https://www.makani.ae/MakaniPhase2ProxyWebService/MakaniPhase2Proxy.svc/SmartSearch";
                    ServiceUrl = global.hostAddress + "/Home/GetQuickSearchData?RequestUrl=" + smartsearchUrl;
                    this.DoAjaxServiceRequest(ServiceUrl, Param, "", "", "QuickSearchRoutingPopOver", "ErrorOnQuickSearchRoutingPopOver", "RoutingQuckSearchProgress", FeatureclassId, RoutingModelName);
                    break;
                case "QuickSearch":
                    var smartsearchUrl = "https://www.makani.ae/MakaniPhase2ProxyWebService/MakaniPhase2Proxy.svc/SmartSearch";
                    ServiceUrl = global.hostAddress + "/Home/GetQuickSearchData?RequestUrl=" + smartsearchUrl;
                    this.DoAjaxServiceRequest(ServiceUrl, Param, "", "", "QuickSearchPopOver", "ErrorOnQuickSearchPopOver", "isAutoCompleteLoading", FeatureclassId, "");
                    break;
                case "VirtualPlate":
                    var smartsearchUrl = "https://www.makani.ae/MakaniPhase2ProxyWebService/MakaniPhase2Proxy.svc/GetVirtualPlate";
                    ServiceUrl = global.hostAddress + "/Home/GetVirtualPlate?RequestUrl=" + smartsearchUrl;
                    this.DoAjaxServiceRequest(ServiceUrl, Param, "", "", "VirtualPlate", "ErrorOnQuickSearchPopOver", "VirtualPlate", FeatureclassId, "");
                    break;
                case "QuickSearchDetail":
                    var smartsearchDetailUrl = "https://www.makani.ae/MakaniPhase2ProxyWebService/MakaniPhase2Proxy.svc/SmartSearchResult";
                    ServiceUrl = global.hostAddress + "/Home/GetQuickSearchDetails?RequestUrl=" + smartsearchDetailUrl;
                    this.DoAjaxServiceRequest(ServiceUrl, Param, "", "", "QuickSearchDetailDiv", "ErrorQuickSearchDetails", "ToolbarSearchDetailProgress", FeatureclassId, "")
                    break;
                case "GetZoningRegulation":
                    var smartsearchDetailUrl = "https://www.makani.ae/MakaniPhase2ProxyWebService/MakaniPhase2Proxy.svc/GetZoningRegulation";
                    ServiceUrl = global.hostAddress + "/Home/GetZoningRegulationDetails?RequestUrl=" + smartsearchDetailUrl;
                    this.DoAjaxServiceRequest(ServiceUrl, Param, "", "", "LandNumberSearchDetails", "ErrorLandNumberSearchDetails", "ToolbarSearchDetailProgress", FeatureclassId, "")
                    break;
                case "GetMapLongPressLocationInfo":
                    this.makaniLoading = true;
                    var GetShareLocationUrl = "https://www.makani.ae/MakaniPhase2ProxyWebService/MakaniPhase2Proxy.svc/ShareLocation";
                    ServiceUrl = global.hostAddress + "/Home/GetLocationInfoOnMapLongPress?requestUrl=" + GetShareLocationUrl;
                    this.DoAjaxServiceRequest(ServiceUrl, Param, "", "", "MapLongClickInfoSection", "ErrorMapClickInfoSection", "", "", "");
                    break;
                case "GetMapTapLocationInfo":
                    this.makaniLoading = true;
                    //this.makaniDirectionIconeShow = false;
                    var GetBuildingEntranceUrl = "https://www.makani.ae/MakaniPhase2ProxyWebService/MakaniPhase2Proxy.svc/GetBuildingOutLine_EntrancePoints";
                    ServiceUrl = global.hostAddress + "/Home/GetLocationInfoOnMapTap?requestUrl=" + GetBuildingEntranceUrl;
                    this.DoAjaxServiceRequest(ServiceUrl, Param, "", "", "MapTapInfoSection", "ErrorMapTapInfoSection", "", "", "", favItem, longPress);
                    break;
                case "GetMakaniShareUrlInfo":
                    var smartsearchDetailUrl = "https://www.makani.ae/MakaniPhase2ProxyWebService/MakaniPhase2Proxy.svc/SmartSearchResult";
                    ServiceUrl = global.hostAddress + "/Home/GetQuickSearchDetails?RequestUrl=" + smartsearchDetailUrl;
                    this.DoAjaxServiceRequest(ServiceUrl, Param, "", "", "MakaniShareUrlInfoSection", "ErrorMakaniShareUrlInfoSection", "", FeatureclassId, "");
                    break;
                case "GetLocationRequest":
                    var GetLocationUrl = "https://www.makani.ae/MakaniPhase2ProxyWebService/MakaniPhase2Proxy.svc/GetLocation";
                    ServiceUrl = global.hostAddress + "/Home/GetLocation?requestUrl=" + GetLocationUrl;
                    //this.DoAjaxServiceRequest(LocationUrl, Param, "", "", "LocationShareUrlInfoSection", "ErrorLocationShareUrlInfoSection", "", FeatureclassId,"");
                    this.DoAjaxServiceRequest(ServiceUrl, Param, "", "", "GetLocation", "", "", "", "");
                    break;
                case "GetShareLocationSquenceNumber":
                    var LocationSquenceNumberUrl = "https://www.makani.ae/MakaniPhase2ProxyWebService/MakaniPhase2Proxy.svc/ShareLocation";

                    var getSequenceParam = {
                        InputJson: {
                            Name: "queryy",
                            Latitude: global.CurrentSreetLatitude,
                            Longitude: global.CurrentSreetLongitude,
                            UserId: "0",
                            sessionid: ""
                        },
                        Token: "l4f76613re4junvvbbd4ufki1j!=+=o6JGpy02dppzxKfVibRYfQ==",
                        Remarks: "MAKANI PHASE 2"
                    };
                    ServiceUrl = global.hostAddress + "/Home/GetSequenceNumber?requestUrl=" + LocationSquenceNumberUrl;
                    this.DoAjaxServiceRequest(ServiceUrl, getSequenceParam, "", "", "GetSequenceNumber", "", "", "", "");
                    break;

            }

        },
        OpenRoutingDiv: function () {
            removeAllMapObjects();
            removeAllRouteMapObjects();

            if (global.currentDeviceLongitude && global.currentDevicelatitude) {
                //this.SetRoutingLatLongData('routingsearch_model0', [global.currentDeviceLongitude, global.currentDevicelatitude]);
                this['routingsearch_model0_latlong_data'] = 'current';
                this.routingsearch_model0 = 'Your Location';
                addDraggableMarker("", global.currentDevicelatitude, global.currentDeviceLongitude, true, true, false, false);
            }

            this.clearRouteSearchBox(1, true);

            this.ResizeRoutingDIvWidth();
            this.IsRoutingDivVisible = true;

            this.routingTourDeffered.resolve();
        },
        OnMapSingleTapClosePopup: function () {
            global.IsMapTapEnable = true;
            this.IsMapSingleTapInfoSectionVisible = false;
            this.isStreetMapLongTapDivVisible = false;
            removeAllMapObjects();
            //this.ResetSearchUIPopOverValuesToDefault();
            this.ToolbarSearchDetailProgress = false;
            this.TSearchClear = false;
            this.TSearchDirection = true;
        },
        OnMapLongPressClosePopup: function () {
            global.IsMapTapEnable = true;
            this.IsMapLongClickInfoSectionVisible = false;
            this.isStreetMapLongTapDivVisible = false;
            removeAllMapObjects();
            //this.ResetSearchUIPopOverValuesToDefault();
            this.ToolbarSearchDetailProgress = false;
            this.TSearchClear = false;
            this.TSearchDirection = true;
        },
        OnToolSearchCloseClick: function () {
            global.IsMapTapEnable = true;
            this.search_model = "";
            this.ToolbarSearchDetailProgress = false;
            this.TSearchClear = false;
            this.TSearchDirection = true;
            this.ResetSearchUIPopOverValuesToDefault();
            this.TSearchMicOn = false;
            this.$nextTick(function () {
                this.selected = null;
            });

            //Clear last search item
            this['routingsearch_model1_latlong_data'] = "";

            removeAllMapObjects();
        },
        OnRoutingSearchItemClick: function (dgsid, featureclassid, routingModelName) {
            if (!this.isNullOrEmpty(dgsid)) {
                this.isAutoCompleteEnabled = false;
                var modelSearchDetail = {
                    InputJson: {
                        featureclass_id: featureclassid,
                        dgis_id: dgsid,
                        userid: "",
                        sessionid: ""
                    },
                    Token: "l4f76613re4junvvbbd4ufki1j!=+=o6JGpy02dppzxKfVibRYfQ==",
                    Remarks: "MAKANI PHASE 2"
                };
                this.PrepareForAjaxRequest("QuickSearchRoutingDetail", modelSearchDetail, "", featureclassid, routingModelName)
            }

        },
        //search item click event on suggestion list
        OnSearchItemClick: function (dgsid, featureclassid, itemtext) {
            global.user_selected_routing_destination_text = "";
            //this.routingsearch_model1 = "";
            if (!this.isNullOrEmpty(dgsid)) {
                this.isAutoCompleteEnabled = false;

                global.user_selected_routing_destination_text = itemtext;
                var modelSearchDetail = {
                    InputJson: {
                        featureclass_id: featureclassid,
                        dgis_id: dgsid,
                        userid: "",
                        sessionid: ""
                    },
                    Token: "l4f76613re4junvvbbd4ufki1j!=+=o6JGpy02dppzxKfVibRYfQ==",
                    Remarks: "MAKANI PHASE 2"
                };
                this.PrepareForAjaxRequest("QuickSearchDetail", modelSearchDetail, "", featureclassid, "");
                
            }

        },
        ViewHideShow: function (ElemntIds, VisibilityState) {
            var isVisible;
            if (VisibilityState == "Show") {
                for (i = 0; i < ElemntIds.length; i++) {
                    //isVisible = $("#" + ElemntIds[i]).is(':visible');
                    //if (!isVisible) {
                    $("#" + ElemntIds[i]).show();
                    //}                
                }

            } else if (VisibilityState == "Hide") {
                for (j = 0; j < ElemntIds.length; j++) {
                    //isVisible = $("#" + ElemntIds[i]).is(':visible');
                    //if (isVisible) {
                    $("#" + ElemntIds[i]).hide();
                    //}
                }
            }
        },
        clearBuildingSearchFields: function () {
            this.community_search_model = "";
            this.street_search_model = "";
            this.building_search_model = "";
            this.community_search_items = [];
            this.street_search_items = [];
            this.building_search_items = [];
            this.iscommunity_search_loading = false;
            this.isstreet_search_loading = false;
            this.isbuilding_search_loading = false;
            this.isstreet_search_visible = false;
            this.isbuidling_search_visible = false;

        },
        doBuildingQuickSearch: function (val, modelName, community, street) {
            var bModel = "";
            switch (modelName) {
                case "community_search_model":
                    this.street_search_model = "";
                    this.building_search_model = "";
                    bModel = {
                        CommName: val.trim(),
                        Lang: "E",
                        Token: "l4f76613re4junvvbbd4ufki1j!=+=o6JGpy02dppzxKfVibRYfQ==",
                        Remarks: "MAKANI PHASE 2"
                    };

                    this.PrepareForAjaxRequest("QuickSearchCommunity", bModel, "", "", modelName);
                    break;
                case "street_search_model":

                    bModel = {
                        CommunityName: community,
                        StreetName: street,
                        Lang: "E",
                        Token: "l4f76613re4junvvbbd4ufki1j!=+=o6JGpy02dppzxKfVibRYfQ==",
                        Remarks: "MAKANI PHASE 2"
                    };
                    this.PrepareForAjaxRequest("QuickSearchStreet", bModel, "", "", modelName);
                    break;
                case "building_search_model":
                    this.building_search_model = "";
                    bModel = {
                        CommunityName: community,
                        StreetName: street,
                        Lang: "E",
                        Token: "l4f76613re4junvvbbd4ufki1j!=+=o6JGpy02dppzxKfVibRYfQ==",
                        Remarks: "MAKANI PHASE 2"
                    };
                    this.PrepareForAjaxRequest("QuickSearchBuildings", bModel, "", "", modelName);
                    break;
                case "BuildingAddressInfo":
                    if (this.isstreet_search_visible && this.isbuidling_search_visible) {
                        bModel = {
                            CommunityName: this.community_search_model.CommunityE,
                            StreetName: this.street_search_model.StreetNameE,
                            BuildingName: this.building_search_model.AddressE,
                            Lang: "E",
                            Token: "l4f76613re4junvvbbd4ufki1j!=+=o6JGpy02dppzxKfVibRYfQ==",
                            Remarks: "MAKANI PHASE 2"
                        };
                        this.PrepareForAjaxRequest("GetBuildingAddress", bModel, "", "", modelName);
                    }
                    break;
            }


        },
        resetRouting: function () {
            this.clearRouteSearchBox(0, true);
            this.clearRouteSearchBox(1, true);
            this.clearRouteSearchBox(2, true);
            this.clearRouteSearchBox(3, true);
            this.clearRouteSearchBox(4, true);

            this.removeRouteSearchBox("4", true);
            this.removeRouteSearchBox("3", true);
            this.removeRouteSearchBox("2", true);


            removeAllMapObjects();
            removeAllRouteMapObjects();

            removeAllRouteMapPointMarkers();

        },
        doRoutingQuickSearchRequest: function (val, routingModelName) {

            if (typeof this[routingModelName] === 'object' && this[routingModelName] !== null)
                return;

            var model = {
                InputJson: {
                    searchtext: val.trim(),
                    lang: "E",
                    currentlocation: (global.currentDevicelatitude || "25.2642691390032") + "," + (global.currentDeviceLongitude || "55.3119033649999"),
                    distancetype: "KM",
                    level: "1",
                    userid: "",
                    sessionid: ""
                },
                Token: "l4f76613re4junvvbbd4ufki1j!=+=o6JGpy02dppzxKfVibRYfQ==",
                Remarks: "MAKANI PHASE 2"
            };
            this.PrepareForAjaxRequest("QuickSearchRouting", model, "", "", routingModelName);
        },
        OnRouteDivCloseClcik: function () {
            this.search_routing_items2.length = 0; this.search_routing_items3.length = 0;
            this.search_routing_items4.length = 0;

            this.resetRouting();

            this.IsMapTapEnable = true;

            this.IsRoutingDivVisible = false;

            this.OnToolSearchCloseClick();

            closePlayer();

        },
        getSTreetLevelUrl: function () {
            var strUrl = 'https://www.makani.ae/desktop/home/streetviewfullscreen?location=' + this.streetLevelCurrentLocation[0] +
                ',' + this.streetLevelCurrentLocation[1];
            return strUrl;
        },
        CallFeedback: function () {
            var windowSize = {
                width: 500,
                height: 500,
            };

            var windowLocation = {
                left: (window.screen.availLeft + (window.screen.availWidth / 2)) - (windowSize.width / 2),
                top: (window.screen.availTop + (window.screen.availHeight / 2)) - (windowSize.height / 2)
            };
            var params = 'scrollbars=no,resizable=no,status=no,location=no,toolbar=no,menubar=no,width=' + windowSize.width + ',height=' + windowSize.height + ',,left=' + windowLocation.left + ',top=' + windowLocation.top + '';
            window.open("https://geodubai.dm.gov.ae/en/Pages/ContactUsForm.aspx", "privacyWindowName", params);
        },
        CallPrivacy: function () {
            var windowSize = {
                width: 500,
                height: 500,
            };

            var windowLocation = {
                left: (window.screen.availLeft + (window.screen.availWidth / 2)) - (windowSize.width / 2),
                top: (window.screen.availTop + (window.screen.availHeight / 2)) - (windowSize.height / 2)
            };
            var params = 'scrollbars=no,resizable=no,status=no,location=no,toolbar=no,menubar=no,width=' + windowSize.width + ',height=' + windowSize.height + ',,left=' + windowLocation.left + ',top=' + windowLocation.top + '';
            window.open("https://dm.gov.ae/website-policies/security-privacy/", "privacyWindowName", params);
        },
        doSearch: function (val) {
            if (val.length <= 3)// user can search even without clearing the X button in the toolbar search
            {
                if (typeof this.search_model === 'object' && this.search_model !== null)
                    return;
            }

            var _self1 = this;
            if (!_self1.isNullOrEmpty(val)) {
                if (val.length > 3) {
                    var langKey = "E";
                    var arregex = /[\u0600-\u06FF]/;
                    if (arregex.test(val)) {
                        langKey = "A";
                    }

                    var model = {
                        InputJson: {
                            searchtext: val.trim(),
                            lang: langKey,
                            currentlocation: (global.currentDevicelatitude || "25.2642691390032") + "," + (global.currentDeviceLongitude || "55.3119033649999"),
                            distancetype: "KM",
                            level: "1",
                            userid: "",
                            sessionid: ""
                        },
                        Token: "l4f76613re4junvvbbd4ufki1j!=+=o6JGpy02dppzxKfVibRYfQ==",
                        Remarks: "MAKANI PHASE 2"
                    };
					this.ResetSearchUIPopOverValuesToDefault();
                    _self1.PrepareForAjaxRequest("QuickSearch", model, "", "");
                    //}
                } else {
                    _self1.TSearchClear = true;
                    _self1.TSearchDirection = false;
                    _self1.TSearchMicOn = false;
                    this.ResetSearchUIPopOverValuesToDefault();
                    this.$nextTick(function () {
                        this.selected = null;
                    });
                    removeAllMapObjects();
                }
            } else {
                _self1.isAutoCompleteEnabled = true;
                _self1.IsQuickSearchDetailDivVisible = false;
                _self1.TSearchClear = false;
                _self1.TSearchDirection = true;
                _self1.TSearchMicOn = false;
            }
        }

    },
    computed: {

    },
    watch: {
        compassAvailable: function (val) {
            if (!val) {
                if (this.voiceSearchEnabled)
                    this.tour_main_steps.splice(!this.TSearchClear ? 4 : 3, 1);
                else
                    this.tour_main_steps.splice(!this.TSearchClear ? 3 : 2, 1);
            } else {
                var elem = {
                    target: '#compass',
                    header: {
                        title: 'Qibla Direction',
                    },
                    content: `Qibla direction is based on the current location/Selected Entrance location`,
                    params: {
                        enableScrolling: false
                    }
                };
                if (this.voiceSearchEnabled)
                    this.tour_main_steps.splice(!this.TSearchClear ? 4 : 3, 0, elem);
                else
                    this.tour_main_steps.splice(!this.TSearchClear ? 3 : 2, 0, elem);
            }
        },
        IsQuickSearchDetailDivVisible: function (val) {
            if (val) {
                this.tour_info_steps = [];

                this.tour_info_steps.push(
                    {
                        target: '#tour_info_navigation',
                        header: {
                            title: 'Calculate Route',
                        },
                        content: `Click to calculate the route from current location to selected entrance and show it on map`,
                        params: {
                            //placement: 'bottom',
                            enableScrolling: false
                        }
                    });

                if (this.IsMakaniInfoSectionVisible) {
                    this.tour_info_steps.push(
                        {
                            target: '#tour_info_makani_streetview',
                            header: {
                                title: 'Street view',
                            },
                            content: `click on the image to display the street view of the selected entrance`,
                            params: {
                                //placement: 'bottom',
                                enableScrolling: false
                            }
                        }
                    );
                }

                if (this.isBasicStreetPreviewVisible) {
                    this.tour_info_steps.push(
                        {
                            target: '#tour_info_basic_streetview',
                            header: {
                                title: 'Street view',
                            },
                            content: `click on the image to display the street view of the selected location`,
                            params: {
                                //placement: 'bottom',
                                enableScrolling: false
                            }
                        }
                    );
                }

                if (this.IsMakaniInfoSectionVisible) {
                    this.tour_info_steps.push(
                        {
                            target: '#tour_info_share',
                            header: {
                                title: 'Share Location',
                            },
                            content: `Share location info (Makani Number,Address,Place Name, etc.) to others by using other applications`,
                            params: {
                                //placement: 'top',
                                enableScrolling: false
                            }
                        }
                    );
                }

                if (global.appUserId && this.IsMakaniInfoSectionVisible && (this.visibleFavoriteAdd || this.visibleFavoriteDelete)) {
                    this.tour_info_steps.push(
                        {
                            target: '#tour_info_favorite',
                            header: {
                                title: 'Add/Remove To/From Favorite',
                            },
                            content: `Add/remove Entrance location to/from Favorites list to be accessed easily later`,
                            params: {
                                placement: 'top',
                                enableScrolling: false
                            }
                        }
                    );
                }

                this.infoTourDeffered.resolve();
            }
        },
        streetFullViewDiv: function (val) {
            if (val) {
                vm.$tours['tour_main'].stop();
                vm.$tours['tour_info'].stop();
            }
        },
        TSearchClear: function (val) {
            if (val) {
                this.tour_main_steps.splice(this.voiceSearchEnabled ? 3 : 2, 1);
            } else {
                this.tour_main_steps.splice(this.voiceSearchEnabled ? 3 : 2, 0,
                    {
                        target: '#ToolBarSearchDirection',
                        header: {
                            title: 'Directions',
                        },
                        content: `Click to open directions panel`,
                        params: {
                            enableScrolling: false
                        }
                    }
                );
            }
        },
        IsRoutingDivVisible: function (val) {
            if (val) {
                vm.$tours['tour_main'].stop();
                vm.$tours['tour_info'].stop();
            }
        },
        search: function search(val) {
            this.doSearch(val);
        },

        DoRouteSearchOnFirst: function DoRouteSearchOnFirst(val) {
            if (val == "Your Location") {
                this.search_routing_items0 = [];
                return;
            }

            var _self1 = this;
            if (!this.isNullOrEmpty(val)) {
                if (val.length > 3) {
                    _self1.doRoutingQuickSearchRequest(val, "routingsearch_model0");

                }
            } else
                this.clearRouteSearchBox(0);

        },
        DoRouteSearchOnSecond: function searchRouting(val) {
            if (val == "Your Location") {
                this.search_routing_items1 = [];
                return;
            }

            if (!this.isNullOrEmpty(val)) {
                if (val.length > 3) {
                    this.doRoutingQuickSearchRequest(val, "routingsearch_model1");
                }
            } else
                this.clearRouteSearchBox(1);

        }, DoRouteSearchOnThird: function searchRouting(val) {
            if (val == "Your Location") {
                this.search_routing_items2 = [];
                return;
            }
            if (!this.isNullOrEmpty(val)) {
                if (val.length > 3) {
                    this.doRoutingQuickSearchRequest(val, "routingsearch_model2");
                }
            } else
                this.clearRouteSearchBox(2);

        }, DoRouteSearchOnFourth: function searchRouting(val) {
            if (val == "Your Location") {
                this.search_routing_items3 = [];
                return;
            }
            if (!this.isNullOrEmpty(val)) {
                if (val.length > 3) {
                    this.doRoutingQuickSearchRequest(val, "routingsearch_model3");

                }
            } else
                this.clearRouteSearchBox(3);

        },
        DoRouteSearchOnFifth: function searchRouting(val) {
            if (val == "Your Location") {
                this.search_routing_items4 = [];
                return;
            }
            if (!this.isNullOrEmpty(val)) {
                if (val.length > 3) {
                    this.doRoutingQuickSearchRequest(val, "routingsearch_model4");
                }
            }
            else
                this.clearRouteSearchBox(4);

        },
        DoCommunitySearch: function searchCommunity(val) {
            if (!this.isNullOrEmpty(val)) {
                if (val.length > 1) {
                    this.doBuildingQuickSearch(val, "community_search_model", "", "");
                }
            } else {
                this.isstreet_search_visible = false;
                this.isbuidling_search_visible = false;
                this.street_search_model = "";
                this.building_search_model = "";
            }
        },

        DoStreetSearch: function searchCommunity(val) {
            if (this.isNullOrEmpty(val)) {
                this.isbuidling_search_visible = false;
                this.building_search_model = "";
            }

        }

    }

});







