<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">

    <title>GISEC</title>
    <link rel="icon" href="https://scontent.fruh4-3.fna.fbcdn.net/v/t39.30808-6/458998406_947799984059293_5832621096415574829_n.jpg?_nc_cat=109&ccb=1-7&_nc_sid=6ee11a&_nc_ohc=LaOuJBrvXn0Q7kNvgHYx54b&_nc_zt=23&_nc_ht=scontent.fruh4-3.fna&_nc_gid=A9Fy1bHikOyjRJb9r-1kl1m&oh=00_AYBQMfBsZlIcnPzYSFEU92SjS9rlsUlbFu5X4L9AXKyCZQ&oe=67521863"
        type="image/x-icon">
    <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
    <link rel="stylesheet" href="https://api.mazemap.com/js/v2.0.38/mazemap.min.css">
    <script type='text/javascript' src='https://api.mazemap.com/js/v2.0.38/mazemap.min.js'></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
    <link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css">
    <script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>

    <script src='https://api.mapbox.com/mapbox-gl-js/v3.1.2/mapbox-gl.js'></script>
    <link href='https://api.mapbox.com/mapbox-gl-js/v3.1.2/mapbox-gl.css' rel='stylesheet' />

    <!-- <script src='./mapbox.js'></script>
    <link href='./mapbox.css' rel='stylesheet' /> -->
    <!-- <script src='https://api.mapbox.com/mapbox-gl-js/v2.3.0/mapbox-gl.js'></script>
    <link href='https://api.mapbox.com/mapbox-gl-js/v2.3.0/mapbox-gl.css' rel='stylesheet' /> -->
    <script src="http://underscorejs.org/underscore-min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/@turf/turf@6/turf.min.js"></script>
    <link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/css/select2.min.css" rel="stylesheet" />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js"></script>
    <script src=" https://ajax.googleapis.com/ajax/libs/angularjs/1.8.2/angular.min.js"></script>
    <!-- <script src="https://code.responsivevoice.org/responsivevoice.js?key=gIsWPBWA"></script> -->
    <script src='https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-draw/v1.4.3/mapbox-gl-draw.js'></script>
    <link rel='stylesheet' href='https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-draw/v1.4.3/mapbox-gl-draw.css'
        type='text/css' />
    <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
    <link rel="stylesheet" href="http://fortawesome.github.io/Font-Awesome/assets/font-awesome/css/font-awesome.css">
    <link href="https://cdn.jsdelivr.net/npm/material-icons@1.13.12/iconfont/material-icons.min.css" rel="stylesheet">
    <link href="https://fonts.cdnfonts.com/css/poppins" rel="stylesheet">
    <link href="https://fonts.cdnfonts.com/css/frutiger-lt-arabic" rel="stylesheet">

    <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/toastify-js/src/toastify.min.css">
    <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/toastify-js"></script>

    <style>
        body {
            margin: 0;
            padding: 0;
            font-family: 'Frutiger LT Arabic', sans-serif !important;
        }

        .overlay {
            position: absolute;
            background-repeat: no-repeat;
            bottom: 5px;
            background-size: 124px 21px;
            width: 129px;
            left: 5px;
            height: 21px;
            background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAiwAAABfCAYAAADLXpyvAAAABHNCSVQICAgIfAhkiAAAIABJREFUeJztnXt0m+Wd57+PJFu+SbK5hgQSJ4EGeih2Glp6j9OGTtttGzM7MGy7UysNkg8zcw5myzlhe/ZslD2nPcl2Zwjb6bKWyESC6WWSdmuGUigJoBTKcAuxuZTShqBwKXdsyUmIbOl99o9HsmVHl+d5r5L9+5zj44ue93l+fl/pfX7v78pQC+9gN5q1PgDdNccuBDQtiRO7k06LQRAEQRDELKziK+1b+uB2RcDYehvlqQ840gCPIzMVARITTotDEARBEIudMgrLQCf8zXEwtsl+ceoMjjQ4H8JkLO60KARBEASxmJmnsAx0wu9NgqHHGXHqFI4EMtGg02IQBEEQxGLFPfsjKSsVYehF80cZpp5OOi0KQRAEQSxGXDM/+ZvjpKxUwcW2oX1Ln9NiEARBEMRiRCgs7Vv6KGZFArcr7rQIBEEQBLEYEQqL2xVxVowGgbEV8IWCTotBEARBEIsNF7yD3YsydVkvDP1Oi0AQBEEQiw1XoSgcIQ3rc1oCgiAIglhseGBCBduv/sVlWL3ybHzoonPw5KEUnjiUwu9ffMO4dCbQet4KeLvOgvvs8zH12h+RHX8XU++/o39ChgC8g93IDqdME5IgCIIgiKp49B64bGkX/ukH1+IrX7wUzU0l02wR3ybSJ/GDW3+D7//jfUZlVMblbcOyvi9hyRXr4fa2IM+BvAZo/CvQOPDB+Pt4+7f3IH34EX0LeHLdyCJlqtAEQRAEQVSEwReKwMW2qRz09S/34Ce7r0N7W3PNsS8eeROf+MJOTKRP6hZSBf/ylVjzzUF4/V3Ic4BzlCgs4iuvib8dP3YEb+z9EfKnFGXL5TdQvyGCIAiCsA9X7SFz+fqXe/CLOwellBUAWHPhEhx++L+hrVVuvBHal3WjN3Qj2jq7pMa3Lb8QS//mJri8bRZLRhAEQRCEEZQUFl9HC+4Y3gyPx117cAndy8/Er/b+veVKy0e+sRlur1fpGO/Zy3DG+q9bJBFBEARBEGagFMPyw//51wj4W3UttOGza7D9v34N//37/4YPTk3rmqMayz69Ae3nLIHG1Y/1rduAiScOIDfxrulyEQuI9i19cLn6aoxKUbNMQgnvYDeaeC8Y7wVDL4DO8gNZCpynoGlJnMiNUif5OqV9Sx9c7l4w3g2gt+I4jiSAFKZcSUrikENJYbnqq2sNLfbFL3wY742fwK23PWC60nL+p/oMHe//2Bfw/v5/NUcYFWRjiMyOm/GHklL1d9LRMh29DcxnJZwfRCbWZ9n8blccjK2oOc47aP0NyOrzzflBsUFiFFNsxJT/p31LHzzuh6TXt+Jaege70cJflh4v+/7XI0cz7wdDEIwXWqLUXGo9GANc7m0IuAEeOgiOOCanRkxTXnTENFpOrXtfIFz7MdXqe4MvFARD/9yK8TWuJ4P4/LZwwBs6BmAEWdcuy+4dTpwn2c+8xrdjMhapNUzaJbR0SSf8Oq0rRc46owPnL+3C34c3oLWlydBc8wksWWLo+JYL1pgkiUW43SPAQIUnL8JyRPuK2soKAHi1IYulsR7G1oNhAC7cghb+MvzhUVurPDO2Hh1h84s0erW46XOq0BbqhT8cRwt/GS7cYqh/G2Pr4WJ74Pem4A/tovuD3Qx0wheKwB+egIvtMdTehrEVYOwG8VkLJR3rW8fYevhCEUfWlkBaYfnqlz5ieLGl54nP07Klnfjb6/pMU1oCK1YZnsNz9jITJLEQhgD8zSNOi7FocbsUlBAWXHCbB0OP2BxDKdtupi5u7ibsCwWdswIOdMIfjqOJHQbDgKlTMwTA2A3we1P1vNksKHzhIfi9KbjYNjAETJ2bsfXwuB+CP5SEd7Db1LllqONGv8pZQmaxbGknBjd/zhSlxdO6SLJ86lz7XbCI9hXyT08MAfiaF2YLB8ZWwON+yJb3IWMr4G82aZ2BTjC2y5y5FOkI98PvTZmuqMyHIQAX2wZ/eBRtocqxE4R+vIPd8IeSBeuYuYrKfBhbDy8fhS9sv8W2Ti360grLH4+8bfriS8/rRCj4WbQYVFoyr6QMy5KffM/wHLbgYtssMZUTlWnWgsrHMERMl6OeEBtj3PJ1GLvBlM3X791l+QZTdt3QLrjxS1vXZuhBEztMjVpNpn1LH7x81FYrHUMALtwCf8heBYIhAL83adt6kkgrLMlHXkR2Kme6AOedG8CWv/m0IaVl+uRxnEobizmbfut1Q8fbigtxR0yFixXG1J9wGFtRr2ZV02AYsOXpz8Piho5v39JnuXWjHP5wHIzdYPu6RVxsDyktJuELBeFxP+SI0gsAjG0SCoStSkuPiI2qH5RcQofHXrFEiCXnBBD8xicNKS1vjx0yJMPkUwcMHW8rDAF4OcWz2IGI/td3k1KKe2lQXLjFcuWZoceQYuR223/T9YfjjihJ8yGlxTi+UBAutsdpMYQCYbfSwm6oJ4u+ksLy3f8xgnxes0SQJecE8K1rP6FbaUk9cC/y2VO6jp1+53V8cOxFXcc6Rh1qvwsSPdaV2WM3LQpLmJdHLF+DIaLrXPpCEUOZOHrwh3bVhbJShJQW/bSFeh2LfSoHQ4/tyRd1ZNFXqsPy0MMv4o6fPYbN3/yUJcKce44f3/irj+MnP38CpxTrtJw6PomX7rsLF379r5WO87py+HPyl0rH1A1C+03ieLRxrC2cH7Rw9lFTZxOuBGObXbMWRHaBx7MwDMA7GLG09gxDAF5tF7KQf9rzDnaDcXutXB3hfjDodwNxflAUFGMT0PKjYO5OUVCOdQNcPrV+PoztQltoFCdj5n5GFjQDnfBgRLeFlWMM4ElwTICzUfD8xGxBOab/3lJMvpCoW2IKRYt+tkoRPJtQ7tb87b9LIOBrwV9+/aNWyINzz/Hj2r/8GH76iyeQzarFzLz6yINoP28Zzr38M1LjO5qBN554DCePPKtH1PpAaL+9DVMp0criTWbjdgcNzyEsNBHD8+hFtfBZ+5a+wv/dr3Sjbub9yMLaJ1HGNqEj3C+toHu1OBizMeZgoBMuxJUP4/wYOCJVCsDN/r/F66NqwWEIFGKBqm86YhOMKM0NyBUlA6wrxGcF/ma5QpHz4Uggyyop8MmZn7yD3WjWgmBsSFkpcrFtaAuN2KaAMvTAH44jEw3asl4FdKU1/8dvDeP2xCPKVhBZzjnbh2uuuhxer7I+hT/suxNvPVM7nqWzBXj30O/wxq/u1CNi/TATz1J/KWgNjXew2xSzPkOgoczxJ3YnkYkGkWW94glREsbt8XPL1mbpCPfbXnNFTyaSxrcjE+sW7RwkqtUWr08uvwGcH1Nay2gs0GJCFIpUKwTHMYZTbKX4/Eg8QGaHU5iMRZDJdoPzu5Rl9Fj8gDAfhgGn72W667CEbrgTkR13Y+y513Dk5Xfw3vsn8N77x/Hue8fxzruTePudSbz1TgZvvp3Bm2+l8cabafz5DflMnrPP7MBfbVqnT2n5cRTvVFFamj3AO08/ilfuukN57rpEBGPVj591IaAnlbkSRuJgnCI7nEIm2ye/KTJ7zMWMrYCvucb51GnpMEJbqFdJweVII4+rdJv1T+xOIjPVq7zRMUTo4UYCtyuiNJ4jgUxUp6U7MYFMrB8a36x0mHANBdXXM4BwLTrmGlLXBkrYues30DSOL6y/GLmcBo1z5HJ55PPF7xryGkc+ryGXyyOXUwvYPfvMDlz11bX45a8OK7uHXvxpFBfxEM78yOWnvZYa+ReMP/2w0nx1j9B+k9R4zyRklAwRjzNR80mMoQftW/pM7QVlC4kJ8FAEDLUzJOxM96xlDvc3R2xPP/UoKqX5fL/x90NiAhn0K2UkFYsaTtqs0DUSwroib50TykrQ8LqTsTh8IShlJIn7VNzw2tLrFV2LA31ONN80XOn2B//7fux/6AUzZCnLWWd2YNNXetHcrK5b/elnMbz54OwDCM+ewqv7YgtPWSnisPa7YJBNZdbYLuQ1OcuWGfEwTjA5JR/QbWcmQSVzuNhs7K19ouo+1HCjqcprJjuk5r5b4EHgRlEpR8AxZmpcx2QsDg03So9n6LH9nu+gRd+U0vz/8E/78cDBP5gxVVnOOrMDX/vSZbqUltQDv8Yrd/8EWvYUUj++FePPP2WBhHXCrPZLJl8jyFlXjuF4dAQndiel3CYik6bbBOlsRuEpypPrtk6OeTC2vmw8hhM1V5oV4nc4P4jJqMkyJiaQ40Hp4YytoAebCqi24VA577JMRncpZVOqWvfMwKF4FtN6Cd3yfw7ggaR1SsuZZ7TjK1deqktpeevxg3juH7+L9LGjFkhWZ1A8izFELELtdENeYoblknUazIyLqUe4y14T8fx4DF94yPaaK0KOoPTYvBaxRIaTsVFwJKTHuxXSwxcTSsonEpZl6Si9T3ifJTLUwgGLvqnND2/9vw/goYetK8B2Rlc7/uLzH9altOQ+OGGBRDbCkZYea1fJ9IWI7NPKlCs+8/NkNl5xXCmNGHyrYq0z6+Yt+3QpOpjHARTdMhHJ+dUzMioy0CmtJHF+0NI4piyLSI9l6LNMjkaGKWz+KudbFWG5lfwcsBWmWm9l9xqGADywNUPVUNBtOX44/BA0jeMzn7jQ7KkBCKXlyg2XYP9DL2DKgt5G9QuPgysUG3LhFrSFknVXKMqKLr+mFVAa6JSKReD8LmSjqdk/JCbAw4maxxZTnBspMNqJrtMcSYCPSsWiMLZJ1CbRhqRqrnCkkZkKIuAdN0FSoN0j/4TJLQ6OzA6n4A2PSd0j7E75bhhYn9QwjjHLa19xxMEgd52atT5kTXp/aQjCDblqqqKjehwZeyx2pissAPCjWBKaxvHpK1ZbMT26Otvw+c+twQMH/4Dp6bwla9QdHBOYYv2iW6hkBoTQfnudiOauiItts2DWiCmz1EyXLVAu0Dafj8Pjrq3s2B3Vb4iBTgWrhbkVjDNTEfib+6UKd7nd8tVINQTF5yFsUMACLlef9NgpV9KcRasgNrlbpMZ6B7sbpuCkXci+j7gNvdwmp0YQ8MpmDHWbtu7x6Aj8oVulg9cZ2wRfeMj82KzTMdUlVMptuw/i4X8/YtX06Opsw4bPrkFTk9uyNeqO7HBK3HAlKWq/hBwysQicHytr1j+xOymVqeFEVL8uBjpFITTpSp8mW/ISE8hLxvzIbzJ3OdbGgvNjtigHWl7+OtgZJN0IqHRX17SkZXLMkJiQroPEWLepS2diaplnwqJv+X3NMoUFAIb3/BaPWKi0dAba8LlPXbS4lJbj0RFwfqv0+KL2S1THFwpKbc7VAmw5l3vCcCKqX5qBTvhCQfibR5VSdXMWWI2EH1/+vV6NoivIbORjQVKmr12OE7n6cgEvVOwLME/JDePdpq+cZf1KsZM2xLNY4hIqJZZ4GJqm4YrLV1oyf8Dfik9fsRq/e/ylxeMeysSG4A+rxbO0bxltvMJlNiKb6VEtwHZyakSqPDvDADAwZIurzh9Kyg9m8gGkpXB+0LJYKRXXUDU4InXlGrUME91dRGXqLTbQCrLDKTSFVeNZRpCxLqDbUgtLkd13/g7//oR1KcV+Xys++bFVi8vSoqr9ut3Ub6gSooV87eA2jkT1TS8xgdJGddWQjZcxCmPr5b90pgRblaoLQMk1VAlLap8QxCLgeHQEGt8uPb7YSdoibFFYAGDPjx/FY09aqLT4W/Hxdd3weGz7l5wlO5xCPi8fmS1SQJ3x39c7si6afD5ec0xO0i2kUrujnuH8Vsstd0ZcQxxpZF1BcwUiFj0NEYdmEpOxiFJQvYttU4oHUsDW3f2Onz2Gxw+9bNn8vo4WXL52ESktJ3Yn60n7bUxkU5kxJrUxn4yNSn24GVvhdOdTw3AkkInZYynKTEWUuxMDwhVkbbCrrGug20IZZrFooyDmwTSbrNVMch2WslSMzFRdWPQtj2GZz50/ewz5vIbL1xpzSVfC1+HF2suW4/Azryg3W2xIJmMR+EPyzbqE9pu0VqgGQto1wydMV/aElSVu6px2YVbDN2kSE8hvCcLjfkj6EM4PYjJmrSuIYwJMYlyxuJfVmUIut/yTf86Tsk6QBuREbhQBybACkc6etE6YAvJFCVPWCpKYQH5Lv/Tnr2jRN9ldbLvCAgA/2fcEOOdYe9lyS+b3dbSg59ILMPbcq4tDaclM9cPvTUmnd7rdI7Ara2E+ufwGR9athKxrRsR4mFtsi7H1aAv1NlwAn8a3m1esT4ETu5Pwh+6S6vVilyuIM/lrZ2Zxr0ow3gcpDQqgGizzUQhYZqwfZtV/qkRHWKFNgML7UC8ndifhC22XrqXF2Hqze3s5orAAwE9//iTyeY61l11gyfztbc249JJleO6F1xeB0qJD+4UDPVcA1FWmUke4HwzWmPpkEfEzQUdlkIUjgSyLzK3yazOZqaCUcm69K0gwzUbh5nJjLbeoDXRKN+4zu9DfQoHzg1LWaoYeyy1mLoXqsdM2KCxA0aLfK/0+M7m3l6PBHnt/+RSeHnvFsvnb25vx4TVL4XYvgpiWE7uTSm3JCcDFna+HIlKc6z97a5qvRSYadP6pPDFRs3iinVlB2eGUQnGv9ZbGmKhknnEb3BmNiMp58fKIZXKI3lhydZDsKkpYJDMV1BVPZgKO7+T7Rg7h8DPWKS1tbc24+KIli0NpEW3JTWzstoARbeTro5+KXSnORvDUkRVIFE8s/z53JitIPvvO7YpYI8JAp1JzzbyCzIsJlfPCMGBq08FSvGXaf1TG5muZmEDOmW7fpu3iPRdk8b+ufVfXsf/v7sMYffZVs0Q5jba2Zly0+pzFobQ4qP02FFY+HaliZYpzOsoqfqnEEzF2Q11loGSmgmWzFuxyBZWiUuWXsfWWVJ72N8flWxRgrOHipuxCZPnJ3z+9FvQU6gj3S7tcAGuqTNfiZGzUCYu+KTt47/Ip3HvTWxjccByxb7+ta46Re0Yx9uxrZohTltaWJqxeefYiUFqc034bh4FOoI7OEWMrlALszEK1vonbFa8f91UZ1xDHmCMF4k7GRpX7rph5vX2hiNIGJ9tCYrFSrf3GfBh64A/HTVu7LdQLl4ICYmWV6Vo4YNE3vHuvXTGNX3/nLfhaRWDrtVccx7/+7RsItKqXyf+3e8fw7O9fNypSRVq8TehefiZcLsko+kbFIe23YfB5g9JPo3bhVDyNSn2TemumOd81lONBx2RRVQJciJtSh8cXHlLqgM75MUzG4obXXchMZuNKNUcYBkxRWtpCvfCwpNK9ydIq0xIIS6e8sm4QQwrL2hXTuKdEWSnylctO4r7vvKZLafnVfc/guRfUlZbW1UvReuEytF54PtouOh9tH7oAbR9ajrY1F6BtzXK0X7IC7ZesgNfrwfLzz1j4SstkdJcoJU+cBquDYNv5MLbeMn94VRRL3zO2yRFrUCWKriGNb3fUzTEZiyvduBkCcLE98Id26bNaDXTCHxqBC7coHcYtTsVdECQmlM+TUFpGdVfA9YWHlJUVzg86n3WZmECOl3fPWoDutOa1K6Zxz01vw9fCgTJZfZeeP417v/MqvvwPFyD9gVqPn1/f/xw0jePii5ZIjfec4cPS669CngN5AFrhe54DWuH3XMnfJ3+fQuud9+PF+5+GpkmmJDYimewQ/N5es1PLGhrZVGbOD5r29OJ2RaQCfL08gqwDwa2ivsmtYOwGqfEuxIGB7vpoJpiYQHaw19FU6yL5/JBSYTtAxAb5m/vBQxFMTo3UPqcDnfA1D4GxIWUroSikF1c6ZrEyGd0FfziodO9k6EETOwx/uJD+LxFL1RHuh4sP6arxVC8tJ07GRuELDYGxPVYvpUthEcrKO/C1VK9vcumyadz7X17Fp77XrbzGfQeeh6ZxfOjCc2uOberyKc3ddkk3PvT9MLq+9ns8+d3bMZ0+oSxfY5CYQC4UVNbcrUSpe7AOMrG+qq+7+JBUYS2OuGlPLx3hXXBL3ZD6xdO2A4qASldkUcUyjkydxAE5nmpdQFXxK8LYCjDsgd+7CwglwTEKTUvOvu7uBOO9YJCvfzEf6qmkTo4H0cQOKx/HMIAWPgBveAycj4CzUfD87Gfa5RbXErxPPDzpsPZruLFu3veAsDD6w33Sqdg6UVZYepdP4Z6b3oOvtbxlZT6Xnj+F6MAbCCfOUxbu/gd/L6206OHMT3wYH4/dhN9dI9+Op+GwUfuVwslUYu9gNxiX6cqcNvVJ9Hh0BP7QsZrKAEMAPm8Qk3AgKFKx9D1jm+ALBemJfR6Z2FDhxq1u1WQIAGwTGDbB5d42/0VDaKiDGjoNhrh3boZL572ToQeMFd4H5bwMOq8pR6Iuu4/bYNFXjmGJXpcWyooC116Rwd99/n3VpQAAB5Iv4A9/fFPXsTIEVi/FxVv/k2Xz1wXCv07xLNKpzDxu+tpcMvLfyfga1awhxnY5E3dT52SyfXYGItZE45txPEp1V/QwGYvr7hRuBRxjyGTrLwYPgB3xLEoKy+b1J3HJspyuhb77H97TFYQLAA/+9g/445G3dB0rw4qr+9B6/tmWzV8XZLJDdXUTtR2FVOasy/ynlylXXGqcUynORZSyhhCAV4tbK1AjkpioG6VF45vJCmaQTGyoLh74hLLSVx+xYxUQGapBq6ZXUliu/4L+WA9fax7/+ZP6Fa/kI3/EkaP6arzIcP43Nlo2d32QmECWqbUIX0j4mvul4ng4P2iJ6VyUcJerWeBoywDlrCFrCqE1PEWlxcGePaSsmEcmGoTGNzu2Pud31b2yUkSUG7DEKqWksFyyTJ+FpMhnLzIW3PrbR/+El15+x9AclehcY00TxroiO5yyUvuta5hkmqKmUDRKlbxkuW3HUpwLKLuGECHXUDkSE8jE+qBxe4PkOD+Gab6WlBWTmYzFkctvsL2SuMa3IxPrbwhlpYiwSpluYZRWWD7aPW14seVnGp/jkceO4GhKXwuAagQuW236nHWJhdpv3dK+pU8q+4XzY5b6+oUiIHezc7p1gLJryIIS5QuFyVgE03ytLdYWjW9HZqqXSu9bxIndSWSmem25h3J+sKB4RixfywossOhLKyyd7fVTr+TRx1/Cy8feM3fSBV5Hbg4Wab91i9sl57KQDYw1gnzZ735ny+CruobQA18oYpk4jc7J2GjB2rLZkid0jgROsZVic2ugJ/GGJDGBTGwIp9hKS2JbOMaQx1XIxPoaWvG0wKJva2Md1QJy1XjsyaNIvSIsLdk/G1depo+fMjxHQ7FY4llEV2a52hWygbFGmMzKrcEQgK/Z2Tonqq4hF9umu9LnYmEyFkcm1i1cC0gY+gxyjEHDjTjFViITpbRlu8kOp5CJBnGKrYTGtxtSRDnS4Eggl9+ATLR3wWR1mWzRl67D8uDzzYYXe+U93YV1y/LEoRQ0jWPpkk7kxifBOtUKyJWSGT1iomQKTLni8OSSNcflPClT180Op4DBXnhy3abMl8MQWL5OGuOVkD01AY+ndldi7pqwp1pqYgLTobVgWu1zVe2a23W+M1MRtHvkb555T+Wn+xO5UbSj9rUw+71edg2FTtVWIIoSJgEIl+VsMbFuAN2nuTCL7iSOJIAUplzJulJQnDyfMmtzl3VWp+xwCllEgEIsV7PWJ64lhPI+v/YUxxjAJwCWAsco8jxpiyXFqWuUiQ2hfUv1e4jkZ57BF4rINs/6xdA4vviRUwDnADjAC5VuuVb4HQC0mdf5zDjx/ZvDy3D3mH6lohJrL7sAPdd/DR2f6ZEqzV/69+Lvz33vX/D6Lx+WWzCX3+B8DweCIAiCWDwouYR+tL9d90LPve61RFkBgMPPvIpnEvuhnZrSdfypt8fllRWCIAiCIGxHSWF58Plm3J5sU15k8gM3rr9jqfJxKjz92J8w+kN9br/ntztfE4ggCIIgiMooB93eeGcA+x5vkR4/+YEbW39+FsZe9aoupcyjdzyAIw+oJb88+70f493HX7BIIoIgCIIgzMAN77o+MNanctBdT7fig2kXPrZyCl5PIU5lhtmfHz3Shm//8xLc/3yHOdJKcPS+J3Hq7Qks+fjFYE0eFKUrRNnMfJ18exxP3DSMNw8cUl9E4wlMH06ZKDZBEARBEFVQCrqdT1e7hm99+jg+syaLQKsGMAaez+HZ15px9+F2HHyx1Wx5pfF2daD7Sx/H8g09cLe3IM8Bzjkm//w+XnvwMF7/zZP6J6egW4IgCIKwFUMKy6IlHV1MZeYIgiAIwnFc0LSk00I0FHb3kSAIgiAIAi5RzXIRVDw1j4VRgZAgCIIgGohClhCPOypFI5F1WdfNlyAIgiCIsgiFJTMVISuLBByJuiqHTRAEQRCLhIKFJTEBzuU62i5WONLIZOkcEQRBEIQDzLZPnnp6FN51KwtNm4hSONLI8T5M/3PKaVEIgiAIYjHinvNb9tAImj/KVAvJLWiKyood3TQJgiAIgiiL+7S/TD2dhKf3IBjbAMasb19fz3AkkMl+iSwrBEEQBOEs1Qug+UJBMPQDrA8MAZtkchZRZ2UEWdcuCrAlCIIgiPpAvmKrd7Abnly3daLUAVRunyAIgiDqEioxTxAEUY5AeBhAGEAU6ejg7N9DWwG2A+BHgdyVSO85evqxoY0A2w9gtpVH6d9qwm9GOrazcNxLAFtV85DSliE1j+E7gVy0rOylBEI7ALZV/OI+A+nbxmvKEQhfDWAjxLkrMl5Yc9/MmrrPR5nrMkfO6dUV/y8h297Cb9cgHd2HwOZVQNNLEjIcQDp2ZcWX5849iHQ0Wn7c9V1A/v3CnDuRjt1c+B/0XOf9ANtYVbbZ9+vcMTPHznt/zz329DFGzlcgHAZ4GGDrSv4aBXAA6ei+WjO6ai9KEARBnA5bBXj21h5Xj7CtQNNLCFy3ruKQwPVdACtROnLhimNnjgnvhdi054/tEptm00tiAzUbz86Sn6+uMrDwGj8ks0EqkY7uA/ihwvxVZCg9j6VyG4FtFEpbHSPkG56nrADivbJXKEfV8VgiGEHtl650AAAFnklEQVQQxKKArUMgtGPmKbka6dgBzLdqB8K88FPlJ/IZSqwM0pQ5JhDaCLFxrALYMIDLyx+bCwOsC8A4hMKxFYHroxWtLGLD2Vj4LQpM75y1poTDAN9asCB0ATDhfJSQvm0cgXAUQLhgaTn9PAU2r8KMwsIqzM2vLMilExaFOLcbEbhuHdK3HyozqKiwVDiXeq4zIK5P2HxFrCqS5ytw3bpZC1ipVem6dYArDHFOas5DFhaCIAhDsK1iQ24Q0rEDACtsiKc97ZZS/J9uxozSki9vOQiEwwXXASCUjcE5bpl0NIp0bLV4TUK504VWVEK6Cu6ZecxYXsaVlCEVxLwFJYSdLoNwgxXcPpoVMgxXtZo5hmtWptLrn779kHA1Ta+WUdJIYSEIgtAFPwCg+DRbpxtFJXjXzI+B67tOe1koIKsws7nzwmbCK7hzeEG54QeqKgNWKQqA2PzENSmRZw5FGU1yw1SiOD8Ln35ui0oMP1DB+mJgTX4UwhK2t+w1dZZZS1I5l2CtWKoC5BIiCILQSzp6DQKhp4Slgu1F4PrLpQJTdcF2IBCuEKeg4MoIhK+eq2CUdUuEhbemuPl6okB+B8BWIRC+eo7bQQSRFpU1A+4UM2D7AGwULpnNq0pcUlcDKFg2clVcJmw/AhWMZaXBrlXJ7QOadmDWIiWUNHGewiVyVpJBz3UeB3JXAk1PCUUzPwzgGjl5jSB7vtwHgNzRghuy8P9xYWlRcH+RhYUgCMIQuWsAjIubcU4y68Uu2A4EwnzOF7BXyMqPArnTs0OE26KggHjEZiuUmoJ1ZL714lTJ0zyzSFmTZI5LpjT4dkbmfbJP8/pl2HMUM5a30uDbmWBba1xSYt3i9by6roJw07cVFCqUKGpsR8n7U8oqRBYWgiAII6T3HEUgPAihCKwrbBQWWBr0BmMqz1U02c8LCtWiIkCSbUQgtHH2Sb9lHMgX560DVwTfWdgMRfBtYPOq2fgaXiuw2WDQ7cw8UeH+mRN8K+mSMnCd09F9CIR2iv+9EIQLXvs43SicL6FQCavPjFuIbYUIwr4ayK1CxQBwAVlYCIIgjCJSWgvBhGwrZrNlHIbfjHSUCfO8VnUzAIC5mzvCcy0zrqdmB5YElKZvG59N562H/9szL/jWU5LKbIYyIkE6dmD2nLCr5wbbeqyL4xFr34zS2KqKtV1mrGHVlMzCa9xcq1Q6tlN8Rc/AjFWIrStksFWEFBaCIAgzEE/FhY2CWVBrxCAiKLUYELqjfJBwk6zc4UKacIFimjDbWDVjypIaLPM4zX1VvBaVUpmtYuachFHRamUV7sHZINzTauIUmFEyr557LQsI5bXwHmHGFZZK136Oe4xVtdCRwkIQBGEaMxtFfZKO3TwrHxue85qIIShuboMzlpn5XzPHe2Y3QpFJVNwAhxEID8/ZBAPhcKGS6w6ZAmHG4UXFcSPEpj0OuG2sTwIU1ivWsCm6pOyRQVi9agTdekrjffbPsW4Iy1ThOvGjhmu7BMLDhWt/euFAUbm4gLuqBYxiWAiCIMwifds4ApsL2RpVTe06qJY9AlQtST+XQQD7Cyb4rbPxErliZtBRpGPVrBFRADsKabs7Zy0GniuB3N7C5hwGmsJzM0gYIDZIi9OKIVwygdChWQsBl7RsVMl6EedltbwMt40jEIqWFEyTdEmZdJ3Ttx9CIHwNZtsFlJPvGtEega0CsL/89aqm+Eifr0OYCUxHhf+P31zrGpGFhSAIwkzmZmvUHyK+osQ1FNpYMP/Pui2qMvNk3gXkZp+W07eNF3rHXIM52SCAsMrwmwH3atviSOa4gHI2u4PKrWu3SwrF2KrKCmI6dgCYXl1mzPjs9TKhXkw6GhXxKvzm2Vo5RfgBANeYF1BOEARBEARBEARBEARBEARBEARBEARBEARBENbx/wG3MEI/GAQ8nAAAAABJRU5ErkJggg==);
        }


        #map {
            position: absolute;
            top: 0;
            bottom: 0;
            width: 100%;
        }

        .mapboxgl-popup-close-button {
            position: absolute;
            right: -4px !important;
            top: -5px !important;
            border: 0;
            border-radius: 0 3px 0 0;
            cursor: pointer;
            background-color: transparent;
            color: white !important;
        }

        #menu {
            background: #fff;
            left: 0.5%;
            width: 50px !important;
            border: 1px solid rgba(0, 0, 0, 0.4);
            flex-direction: column-reverse;
            bottom: 5%;
            /* width: 10%; */
            width: 34px;
            position: absolute;
            box-shadow: 0 0 0 1.5px rgb(0 0 0 / 20%);
            border-radius: 5px;
        }

        #menu a {
            font-family: monospace;
            font-size: 25px;
            border-radius: 5px;
            color: #404040;
            display: block;
            margin: 0;
            padding: 0;
            padding: 10px;
            text-decoration: none;
            text-align: center;
        }

        #menu a:last-child {
            border: none;
        }

        #menu a:hover {
            background-color: #f8f8f8;
            color: #404040;
        }

        #menu a.active {
            background-color: #0084ff;
            font-weight: bolder;
            color: #fff;
            display: flex;
            flex-direction: column-reverse;
        }

        #menu a.active:hover {
            background: #0084ff;
        }

        #screensaver {
            position: absolute;
            width: 100%;
            height: 100%;
            left: 0px;
            display: block;
            top: 0px;
            z-index: 9999;
            background-image: linear-gradient(to top, #d5d5d5, #d7d7d7, #d9d9d9, #dbdbdb, #dddddd, #e1e1e1, #e4e4e4, #e8e8e8, #eeeeee, #f3f3f3, #f9f9f9, #ffffff);
            justify-content: center;
        }

        #logosaver {
            width: 28%;
            animation: brath 15s linear infinite;
            margin-left: 36%;
            margin-top: 16%;
        }

        @keyframes brath {
            0% {
                transform: scale(0.8);
            }

            25% {
                transform: scale(1.2);
            }

            60% {
                transform: scale(0.8);
            }

            100% {
                transform: scale(1.2);
            }
        }

        .option-image {
            width: 20px;
            height: 20px;
            margin-right: 10px;
            border-radius: 50%;
        }

        #cur_btn {
            border: 1px #c1c1c1 solid;
            border-radius: 5px;
            width: 30px;
            height: 30px;
            background-color: white;
            box-shadow: 0 0 0 2px rgb(0 0 0 / 10%);
        }

        #movecur_btn {
            border: 1px #c1c1c1 solid;
            border-radius: 5px;
            width: 30px;
            height: 30px;
            margin-bottom: 12px;
            background-color: white;
            box-shadow: 0 0 0 2px rgb(0 0 0 / 10%);
        }

        #search_btn {
            border-radius: 5px;
            width: 35px;
            height: 35px;
            background-color: white;
        }

        #search_btn_image {
            width: 25px;
        }

        #cur_btn_image {
            width: 25px;
        }

        #move_btn_image {
            width: 25px;
        }

        #lang_btn {
            border-radius: 5px;
            width: 90px !important;
            height: 50px !important;
            background-color: white;
            color: black;
            font-size: 7px;
        }

        #lang_btn_image {
            width: 25px;
        }

        #uk {
            width: 25px;
            padding-right: 5px;
        }

        #ksa {
            width: 25px;
            padding-right: 5px;
        }

        .foo {
            color: #828282;
            margin-top: 5px;
            font-size: 11px;
        }

        .mapboxgl-ctrl-attrib-inner {
            display: none;
        }

        .mapboxgl-ctrl-attrib.mapboxgl-compact {
            min-height: 20px;
            padding: 0;
            margin: 10px;
            display: none;
            position: relative;
            background-color: #fff;
            border-radius: 3px 12px 12px 3px;
        }

        .mapboxgl-ctrl-bottom-right {
            right: 0;
            bottom: 25px;
        }

        .dropbtn {
            background-color: #4CAF50;
            color: white;
            padding: 16px;
            font-size: 16px;
            border: none;
            cursor: pointer;
        }

        .dropdown {
            position: relative;
            display: inline-block;
        }

        .dropdown-content {
            display: none;
            position: absolute;
            background-color: #f9f9f9;
            min-width: 160px;
            box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
            z-index: 1;
        }

        .dropdown-content a {
            color: black;
            padding: 12px 16px;
            text-decoration: none;
            display: block;
        }

        .dropdown-content a:hover {
            background-color: #f1f1f1
        }

        .dropdown:hover .dropdown-content {
            display: block;
        }

        .dropdown:hover .dropbtn {
            background-color: #3e8e41;
        }

        .dropdown-content {
            display: none;
            position: absolute;
            border-radius: 5px;
            background-color: #f9f9f9;
            min-width: 75px;
            box-shadow: 0px 8px 16px 0px rgb(0 0 0 / 20%);
            z-index: 1;
            margin-top: 10%;
            font-family: -webkit-pictograph;
        }

        .dropdown-content a {
            color: black;
            padding: 10px 8px;
            text-decoration: none;
            display: flex;
        }

        .mapboxgl-ctrl-top-right {
            top: 0;
            right: 0;
            display: flex;
            width: 40%;
        }

        .select2-container .select2-selection--single {
            box-sizing: border-box;
            cursor: pointer;
            border: 1px solid lightgray;
            display: block;
            height: 50px;
            border-radius: 15px;
            box-shadow: 0 0 0 0px rgba(0, 0, 0, .1);
            user-select: none;
            -webkit-user-select: none;
        }

        .select2-container {
            box-sizing: border-box;
            display: inline-block;
            margin: 0;
            position: fixed !important;
            vertical-align: middle;
            width: 100% !important;
        }

        .select2-container--default .select2-selection--single .select2-selection__rendered {
            color: #444;
            line-height: 45px;
            font-size: 18px;
        }

        .select2-container--default .select2-selection--single .select2-selection__arrow {
            height: 26px;
            position: absolute;
            top: 12px;
            right: 1px;
            width: 20px;
        }

        .modal-header {
            padding: 10px !important;
            border-bottom: 1px solid #e5e5e5 !important;
        }

        .modal {
            z-index: 1 !important;
            margin: auto;
            width: 75%;
        }

        .modal-header .close {
            margin-top: -30px;
            color: white;
        }

        .change_dialog_class {
            position: absolute
        }

        #change_dialog {
            z-index: 1;
            visibility: hidden;
            width: 70%;
            height: 23%;
            color: #000;
            font-family: "Courier New", Courier, monospace;
            text-align: right;
            padding: 5px;
            box-sizing: border-box;
        }

        .cd-popup-container {
            position: relative;
            max-width: 400px;
            margin: 4em auto;
            background: #fff;
            border-radius: .25em .25em .4em .4em;
            text-align: center;
            box-shadow: 0 0 20px rgba(0, 0, 0, .2);
            -webkit-transform: translateY(-40px);
            -moz-transform: translateY(-40px);
            -ms-transform: translateY(-40px);
            -o-transform: translateY(-40px);
            transform: translateY(-40px);
            -webkit-backface-visibility: hidden;
            -webkit-transition-property: -webkit-transform;
            -moz-transition-property: -moz-transform;
            transition-property: transform;
            -webkit-transition-duration: .3s;
            -moz-transition-duration: .3s;
            transition-duration: .3s
        }

        .cd-popup-container p {
            padding: 1em 1em
        }

        .cd-popup-container .cd-buttons:after {
            content: "";
            display: table;
            clear: both
        }

        .cd-popup-container .cd-buttons li {
            float: left;
            width: 50%;
            list-style: none
        }

        .cd-popup-container .cd-buttons a {
            display: block;
            height: 60px;
            line-height: 60px;
            text-transform: uppercase;
            color: #fff;
            -webkit-transition: background-color .2s;
            -moz-transition: background-color .2s;
            transition: background-color .2s
        }

        .cd-popup-container .cd-buttons li:first-child a {
            background: #2A54A0;
            font-family: sans-serif;
        }

        .no-touch .cd-popup-container .cd-buttons li:first-child a:hover {
            background-color: #fc8982
        }

        .cd-popup-container .cd-buttons li:last-child a {
            background: #b6bece;
            border-radius: 0 0 .25em 0;
            font-family: sans-serif;
        }

        .no-touch .cd-popup-container .cd-buttons li:last-child a:hover {
            background-color: #c5ccd8
        }

        .cd-popup-container .cd-popup-close {
            position: absolute;
            top: 8px;
            right: 8px;
            width: 30px;
            height: 30px
        }

        .cd-popup-container .cd-popup-close::after,
        .cd-popup-container .cd-popup-close::before {
            content: '';
            position: absolute;
            top: 12px;
            width: 14px;
            height: 3px;
            background-color: #8f9cb5
        }

        .cd-popup-container .cd-popup-close::before {
            -webkit-transform: rotate(45deg);
            -moz-transform: rotate(45deg);
            -ms-transform: rotate(45deg);
            -o-transform: rotate(45deg);
            transform: rotate(45deg);
            left: 8px
        }

        .cd-popup-container .cd-popup-close::after {
            -webkit-transform: rotate(-45deg);
            -moz-transform: rotate(-45deg);
            -ms-transform: rotate(-45deg);
            -o-transform: rotate(-45deg);
            transform: rotate(-45deg);
            right: 8px
        }

        .is-visible .cd-popup-container {
            -webkit-transform: translateY(0);
            -moz-transform: translateY(0);
            -ms-transform: translateY(0);
            -o-transform: translateY(0);
            transform: translateY(0)
        }

        .mapboxgl-popup-content {
            position: relative;
            background: #2A54A0;
            border-radius: 3 px;
            box-shadow: 0 1px 2px rgb(0 0 0 / 10%);
            padding: 10 px 10 px 15 px;
            pointer-events: auto;
            padding-top: 10 px !important;
        }

        .instructions {
            display: none;
            position: relative;
            width: 100%;
            text-align: center;
            padding: 10px;
            background-color: #3e4d7f;
            color: #fff;
            z-index: 9999;

        }

        .mapboxgl-ctrl-group:not(:empty) {
            box-shadow: 0 0 0 0px rgba(0, 0, 0, .1) !important; 
        }

        .select2-results__option {
            padding: 10px;
            user-select: none;
            -webkit-user-select: none;
        }

        .select2-results__option[aria-selected] {
            cursor: pointer;
            font-size: 17px;
        }

        .select2-container--default .select2-results>.select2-results__options {
            max-height: 330px;
            overflow-y: auto;
        }

        a.mapboxgl-ctrl-logo {

            display: none;
        }

        #toast {
            visibility: hidden;
            max-width: 50px;
            height: 50px;
            /*margin-left: -125px;*/
            margin: auto;
            background-color: #333;
            color: #fff;
            text-align: center;
            border-radius: 2px;

            position: fixed;
            z-index: 1;
            left: 0;
            right: 0;
            bottom: 30px;
            font-size: 17px;
            white-space: nowrap;
        }

        #toast #img {
            width: 50px;
            height: 56px;
            float: left;

            /* box-sizing: border-box;
    background-image: url(./images/burjeel.jpg);
    background-size: cover;
    background-repeat: no-repeat; 
    background-color: #111; */
            background-color: #860E4E;
            color: #fff;
        }

        #toast #desc {
            color: #fff;
            padding: 16px;
            overflow: hidden;
            white-space: nowrap;
            background-color: #860E4E;
        }

        #toast.show {
            visibility: visible;
            -webkit-animation: fadein 0.5s, expand 0.5s 0.5s, stay 100s 1s, shrink 0.5s 100s, fadeout 0.5s 2.5s;
            animation: fadein 0.5s, expand 0.5s 0.5s, stay 100s 1s, shrink 0.5s 100s, fadeout 0.5s 4.5s;
        }

        @-webkit-keyframes fadein {
            from {
                bottom: 0;
                opacity: 0;
            }

            to {
                bottom: 30px;
                opacity: 1;
            }
        }

        @keyframes fadein {
            from {
                bottom: 0;
                opacity: 0;
            }

            to {
                bottom: 30px;
                opacity: 1;
            }
        }

        @-webkit-keyframes expand {
            from {
                min-width: 50px
            }

            to {
                min-width: 350px
            }
        }

        @keyframes expand {
            from {
                min-width: 50px
            }

            to {
                min-width: 300px
            }
        }

        @-webkit-keyframes stay {
            from {
                min-width: 300px
            }

            to {
                min-width: 300px
            }
        }

        @keyframes stay {
            from {
                min-width: 300px
            }

            to {
                min-width: 300px
            }
        }

        @-webkit-keyframes shrink {
            from {
                min-width: 300px;
            }

            to {
                min-width: 50px;
            }
        }

        @keyframes shrink {
            from {
                min-width: 300px;
            }

            to {
                min-width: 50px;
            }
        }

        @-webkit-keyframes fadeout {
            from {
                bottom: 30px;
                opacity: 1;
            }

            to {
                bottom: 60px;
                opacity: 0;
            }
        }

        @keyframes fadeout {
            from {
                bottom: 30px;
                opacity: 1;
            }

            to {
                bottom: 60px;
                opacity: 0;
            }
        }

        .filter-container {
            width: 400px;
            display: none;
            border: 1px solid #ccc;
            border-radius: 5px;
            padding: 20px;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
            position: fixed;
            background-color: white;
            margin-left: 0.4%;
            margin-top: 70px;
            top: 0px;
        }

        .category {
            margin-bottom: 15px;
        }

        .category h3 {
            font-size: 18px;
            margin-bottom: 10px;
        }

        .options {
            display: flex;
            flex-wrap: wrap;
            gap: 10px;
        }

        .option {
            padding: 5px 10px;
            border: 1px solid #ccc;
            border-radius: 5px;
            background-color: #f9f9f9;
            cursor: pointer;
            user-select: none;
        }

        .option.selected {
            background-color: #007bff;
            color: white;
            border-color: #007bff;
        }

        .filter-btn {
            margin-top: 20px;
            display: block;
            width: 100%;
            padding: 10px;
            background-color: #007bff;
            color: white;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            font-size: 16px;
        }

        .filter-btn:hover {
            background-color: #0056b3;
        }

        .card {
            background: white;
            width: 350px;
            border-radius: 10px;
            box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
            overflow: hidden;
            border: 1px solid #ddd;
            position: fixed;
            top: 0px;
            margin-left: 10px;
            margin-top: 70px;
            display: none;
            transform: translateX(0);
            /* Initial position */
            transition: opacity 1s ease, transform 1s ease;
            box-shadow: 0 0 0 3px rgba(0, 0, 0, .1);
            /* Smooth fade and move */
        }

        #card.hidden {
            transform: translateX(-100%);
        }

        .card-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 0px 0px;
        }

        .card-header img {
            width: 150px;
            height: 150px;
            margin-left: 70px;
        }

        .card-header button {
            background: none;
            border: none;
            cursor: pointer;
            font-size: 25px;
        }

        .card-body {
            padding: 7px;
        }


        .card-body h3 {
            margin: 10px 0;
            font-size: 20px;
            color: #333;
        }

        .card-body p {
            font-size: 13px;
            color: #666;
        }

        .card-actions {
            display: flex;
            justify-content: space-between;
            padding: 5px;
        }

        .btn {
            background: #0084ff;
            color: white;
            padding: 10px 15px;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            font-size: 14px;
        }

        .btn.secondary {
            background: white;
            color: #333;
            border: 1px solid #ccc;
        }

        .translate {
            margin-top: 5px;
            font-size: 12px;
            color: #777;
            margin-bottom: 5px;
        }

        .translate a {
            color: #0084ff;
            text-decoration: none;
        }

        .social-icons {
            display: flex;
            gap: 10px;
        }

        .social-icons a {
            text-decoration: none;
            color: #333;
            font-size: 20px;
        }

        .marker {
            position: relative;
            background-color: white;
            border: 1px solid #ccc;
            background-color: #0084ff;
            color: white;
            border-radius: 10px;
            padding: 5px 10px;
            text-align: center;
            font-weight: bold;
            font-size: 13px;
            font-family: sans-serif;
            width: 125px;
            box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);

        }

        .marker::after {
            content: '';
            position: absolute;
            bottom: -10px;
            left: 50%;
            margin-left: -5px;
            width: 0;
            height: 0;
            border-left: 5px solid transparent;
            border-right: 5px solid transparent;
            border-top: 10px solid white;
        }

        small, .small {
            font-size: 70%;
            color: #4A628A !important;
        }


        .price-slider input[type="range"] {
            position: absolute;
            width: 100%;
            pointer-events: none;
            -webkit-appearance: none;
            appearance: none;
        }

        .price-slider input[type="range"]::-webkit-slider-thumb {
            pointer-events: all;
            width: 20px;
            height: 20px;
            border-radius: 50%;
            background-color: white;
            border: 2px solid #4a4a4a;
            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
            -webkit-appearance: none;
            appearance: none;
        }

        .slider-track {
            position: absolute;
            top: 50%;
            transform: translateY(-50%);
            width: 100%;
            height: 6px;
            background: #d3d3d3;
        }

        .slider-range {
            position: absolute;
            top: 50%;
            transform: translateY(-50%);
            height: 6px;
            background: #ff4560;
        }

        .price-labels {
            display: flex;
            justify-content: space-between;
            margin-top: 20px;
        }

        .price-labels span {
            font-size: 18px;
            padding: 5px 15px;
            background: #1f2632;
            color: white;
            border-radius: 8px;
        }

        .price-values {
            display: flex;
            justify-content: space-between;
            margin-top: 20px;
            gap: 20px;
        }

        .price-values input {
            width: 120px;
            text-align: center;
            padding: 10px;
            font-size: 18px;
            border: 1px solid #d3d3d3;
            border-radius: 8px;
        }

        .navigation-buttons {
            display: flex;
            gap: 10px;
            margin-top: 20px;
            overflow-x: auto;
            padding: 5px;
            scrollbar-width: none;
        }

        .navigation-buttons::-webkit-scrollbar {
            display: none;
        }
        .nav-button {
            background: white;
            border: none;
            padding: 8px 20px;
            border-radius: 100px;
            display: flex;
            align-items: center;
            gap: 8px;
            white-space: nowrap;
            /* box-shadow: 4px 4px 8px #d1d1d1, -4px -4px 8px #ffffff; */
            cursor: pointer;
            transition: all 0.3s ease;
            color: black ;
            border: 1px solid lightgray;
        }

        .search-container {
				position: fixed;
				top: 20px;
				left: 50%;
				transform: translateX(-50%);
				width: 90%;
				max-width: 600px;
			}
            @media (max-width: 768px) {
				.search-container {
					width: 95%;
				}

				.nav-button {
					padding: 8px 16px;
				}
			}




            
            .slider-container {
                display: none;
                background-color: #fff;
    border-radius: 12px;
    margin-top: 5%;
    /* box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1); */
    padding: 31px 13px 2px 2px;
    margin: 0%;
    width: 342px;
    text-align: center;
        }

        .slider-wrapper {
        position: relative;
        }

        .slider-labels {
        display: flex;
        justify-content: space-between;
        margin-bottom: 10px;
        font-size: 14px;
        }

        .slider {
            position: relative;
            height: 21px;
        }

        .slider input[type="range"] {
            left: 0;
            position: absolute;
            width: 100%;
            pointer-events: none;
            -webkit-appearance: none;
            background: none;
        }

        .slider input[type="range"]::-webkit-slider-thumb {
        pointer-events: auto;
        width: 20px;
        height: 20px;
        border-radius: 50%;
        background-color: #007bff;
        border: 3px solid #fff;
        cursor: pointer;
        -webkit-appearance: none;
        position: relative;
        z-index: 3;
        }

        .slider input[type="range"]:nth-child(2)::-webkit-slider-thumb {
        z-index: 4;
        }

        .slider-track {
        position: absolute;
        height: 5px;
        width: 100%;
        background: #ddd;
        border-radius: 3px;
        top: 50%;
        transform: translateY(-50%);
        z-index: 1;
        }

        .input-fields {
        display: flex;
        justify-content: space-between;
        margin: 20px 0;
        }

        .input-fields div {
        text-align: left;
        }

        .input-fields label {
        font-size: 12px;
        display: block;
        margin-bottom: 5px;
        }

        .input-fields input {
            width: 147px;
            padding: 8px;
            font-size: 12px;
            border: 0px solid #ccc;
            border-radius: 6px;
            background-color: #f0f0f0;
            font-weight: 100;
        }

        .search-button {
            display: none;
            width: 100%;
            padding: 7px;
            background-color: #007bff;
            color: #fff;
            border: none;
            border-radius: 6px;
            font-size: 14px;
            cursor: pointer;
            transition: background-color 0.3s;
        }

        .search-button:hover {
        background-color: #0056b3;
        }
        .ruler {
            position: absolute;
            /* left: 9px; */
            top: 5px;
            width: 94%;
            /* height: 20px; */
            display: flex;
            /* justify-content: space-between; */
            pointer-events: none;
            height: 4px;
        }

        .ruler .mark {
            position: relative;
            height: 10px;
            width: 1px;
            background-color: #e9e5e5;
            top: 5px;
        }

        .ruler .mark.major {
            height: 15px;
            top: 4px;  
        }

        .ruler .label {
            position: absolute;
            top: 20px;
            font-size: 10px;
            text-align: center;
            color: lightgray;
            left: -4%;
        }


			div.scrollmenu button {
                display: inline;
                color: black;
                text-align: center;
                padding: 8px;
                margin: 2px;
                font-size: 18px;
                border-radius: 20px;
                background-color: #F4F4F4;
                /* text-decoration: none; */
                        /* border: 1px solid #E9E9F9; */
            } 

        /* Hover effect */
        #selectedCategory:hover {
            color: white;
            background-color: #0084ff; /* Darker blue on hover */
            transform: scale(1.1); /* Slightly enlarge */
            box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2); /* Add shadow */
            
        }

        /* Selected effect */
        #selectedCategory.selected {
            color: white;
            background-color: #0084ff; /* Green to indicate selection */
            color: white;
            box-shadow: 0 6px 12px rgba(40, 167, 69, 0.4); /* Glow effect for selection */
            transform: scale(1.1); /* Keep slightly enlarged when selected */
        }

    </style>
</head>

<body>

    <div id="map"></div>
    <nav id="menu"></nav>

    <div class="card">
        <div id="div_toggle_card" style="text-align: left; background-color: #F0F0F0 !important;">

            <button title="toggle_card" style="font-family: monospace;font-family: monospace; width: 25%;border: none;"
                onclick="toggle_card_fun()">
                <img style="width: 30px;height: 30px;margin-bottom: 0px; padding: 7px;" src="./images/left_arrow.png" />
            </button>

        </div>
        <div class="card-header">
            <img id="img_card" src="https://via.placeholder.com/50" alt="Atlas Cloud Services Logo">
            <button title="close_btn" style="font-family: monospace;" onclick="close_routing()">
                <img style="width: 30px;height: 30px;margin-bottom: 160px;" src="./images/closebtn.png" />
            </button>

        </div>
        <div class="card-body">
            <h3 id="title_card">Atlas Cloud Services</h3>
            <p id ="hall_no">Booth 11B-10 in Hall, 11</p>
            <button class="btn" onclick="get_direction()">Directions</button>
            <button id="book_btn" class="btn secondary">Book</button>
            <div class="translate">
                <span>AI-Translate to: </span>
                <a href="#">Arabic</a>, <a href="#">French</a>
            </div>
            <p id="desc_card">
            </p>
            <div class="journy_info_details" style="display: none;">
                <hr style="border: 0.1px solid #b9b9b9;margin: 5px 0;">
                <p>Journey information : </p>
                <div dispa>
                    <p id="journy_info_distance">Distance : </p>
                </div>
                <div>
                    <p id="journy_info_duration">Duration : </p>
                </div>
                <div>
                    <p id="journy_info_level">Level : </p>
                </div>
            </div>
        </div>
        <div class="card-actions">
            <a href="#" class="social-icons">🌐</a>
            <a href="#" class="social-icons">💼</a>
        </div>
    </div>





    <div id="step" class="instructions">
        <span>
            <h5 id="current-step" style="font-size: smaller;font-style: italic;"></h5>
        </span>
    </div>
    <!-- loading -->
    <div id="screensaver">
        <img id="logosaver" src="./images/giseclogo.png">
    </div>

    <!-- current location button -->
    <div class="mapboxgl-ctrl-bottom-right">
        <div class="mapboxgl-ctrl mapboxgl-ctrl-group"
            style="background-color: transparent;box-shadow: none;margin-bottom: 270%;">

            <div id="move" style="display: none;">
                <button id="movecur_btn" onclick="move_location()"><img id="move_btn_image"
                        src="images/move.png" /></button>
            </div>

            <div id="currentlocation">
                <button id="cur_btn" onclick="current_location()"><img id="cur_btn_image"
                        src="images/mylocation.png" /></button>
            </div>
        </div>
    </div>

    <!-- Search button -->
    <div id="searchBarContainer" class="search-container">
        <div class="mapboxgl-ctrl mapboxgl-ctrl-group" style="width: 100%;">
            <div>
                <select name="Location" id="TO_Location">
                </select>
            </div>
        </div>
        <div style="float: none;
        background: none;
        box-shadow: 0 0 0 0px rgba(0, 0, 0, 0);
        margin: 10% 0% 0% 0%;" >
            <div id="search">
                <button id="search_btn" style="display: none;" onclick="launch_toast()"><img id="search_btn_image"
                        src="images/search.png" /></button>
            </div>
            <div id="scrollmenu" class="navigation-buttons">
                <button id="selectedCategory" onclick="filter_Results(this)" class="nav-button nav_cat">All</button>
            </div>
        </div>
       
    </div>

    <!-- language button -->
    <div class="mapboxgl-ctrl-top-left" style="">
        <div class="mapboxgl-ctrl mapboxgl-ctrl-group">
            <div id="language" style="font-family: 'poppins', sans-serif;">

                <button class="dropbtn" id="lang_btn" onclick="open_filter()">
                    <img id="lang_btn_image"  src="images/control.png" />
                </button>

                <button class="dropbtn" id="show_card_btn" style="width: 90px; height: 50px; display: none;"
                    onclick="show_dialog_card()">
                    <img id="show_btn_image" style="width: 15px;" src="images/right_arrow.png" />
                </button>

                <button class="dropbtn" id="btn_title" style="width: 90px; height: 50px; display: none;
                border-radius: 0px;" onclick="">
                    <div style="color: black; font-size:12px;">
                        <p id="p_tle">Journey Information</p>
                    </div>

                </button>

                <button class="dropbtn" id="btn_distance"
                    style="width: 90px; height: 70px; display: none;"
                    onclick="">
                    <img id="show_btn_image" style="width: 20px;" src="images/distance_elapsed.png" />
                    <div style="color: black; font-size:12px;">
                        <p id="p_distance">btn_time</p>
                    </div>

                </button>

                <button class="dropbtn" id="btn_time"
                    style="width: 90px; height: 70px; display: none;"
                    onclick="">
                    <img id="show_btn_image" style="width: 20px;" src="images/time_elapsed.png" />
                    <div style="color: black; font-size:12px;">
                        <p id="p_time">btn_time</p>
                    </div>

                </button>

                <button class="dropbtn" id="btn_level"
                    style="width: 90px; height: 70px; display: none;"
                    onclick="">
                    <img id="show_btn_image" style="width: 20px;" src="images/layers.png" />
                    <div style="color: black; font-size:12px;">
                        <p id="p_floor">btn_time</p>
                    </div>

                </button>

                <!-- <button id="lang_btn"><img id="lang_btn_image" src="images/language.png" /></button> -->
                <!-- <div class="dropdown">
                    <button class="dropbtn" id="lang_btn"><img id="lang_btn_image"
                            src="images/language.png" /></button>
                    <button class="dropbtn" id="lang_btn"><img id="lang_btn_image"
                            src="images/language.png" /></button>
                    <div class="dropdown-content">
                        <a href="#" onclick="changelang('AR')"> <img id="ksa" src="images/ksa.png" /> Arabic</a>
                        <a href="#" onclick="changelang('EN')"> <img id="uk" src="images/uk.png" /> English</a>
                    </div>
                </div> -->
            </div>
        </div>
    </div>

    <!-- journy information  -->
    <div id="myModal" class="modal" style="padding-top: 3%;height: 35%;top: 100% !important;overflow: hidden;">
        <div class="modal-content">
            <div class="modal-header" style="color: white;background-color: #223770;">
                <div style="float: left ;width: 10% !important;">
                    <div class="destination_img" style="width: 20px;height: 20px !important;margin-top: 10%;"></div>
                </div>
                <div style="width: 100% !important;
                margin: auto;
                display: flex;
                margin-left: 32%;">
                    <img style="    width: 35px;
                    height: 35px;
                    margin-right: 0%;
                    display: block;
                    margin-top: -2%;" id="destination_img_test">
                    <p style="text-align: center;
                    margin-top: -2%;
                    font-size: 20px;
                    width: 300px; margin-left: 7%;font-family: sans-serif;" id="destination_name">Destination Location
                    </p>
                </div>

                <div>
                    <span class="close">&times;</span>
                </div>

            </div>
            <div style="display: flex; height: 50px; align-items: center; width: 100%; font-size: 15px;font-family: 'Font Awesome 5 Free';"
                class="modal-body">
                <div style="width: 33%; display: inline-flex;">
                    <div><img style="width: 40px; height: 40px;" src="./images/distance.png"></div>
                    <p id="distanceLabel"
                        style="font-family: sans-serif;margin-left: 2.5%;margin-top: 2%;font-size: 16px;"> 50 KM</p>
                </div>
                <div style="width: 33%; display: inline-flex;padding-left: 9%;">
                    <div><img style="width: 40px; height: 40px" src="./images/clock.png"></div>
                    <p id="timeLabel"
                        style="font-family: sans-serif;margin-left: 5%; margin-top: 2.5%; font-size: 16px;"> 5 Min</p>
                </div>
                <div style="width: 33%; display: inline-flex;padding-left: 15%;">
                    <div><img style="width: 40px; height: 40px" src="./images/elevator.png"></div>
                    <p id="floorLabel"
                        style="font-family: sans-serif;margin-left: 10%; margin-top: 2.5%; font-size: 16px;"> 3 </p>
                </div>
            </div>
            <!-- <div class="modal-footer">
            <h3>Modal Footer</h3>
        </div> -->
        </div>
    </div>

    <!-- Dialog to change destination -->
    <div id="change_dialog" class="change_dialog_class" style="margin: 10%;margin-top: 20% !important;">
        <div class="cd-popup-container">
            <div class="reroute_class" style="
        width: 61px;
        height: 75px;"></div>
            <p id="confirm1" style="font-family: sans-serif;font-size: 20px;">Change destination ?</p>
            <ul class="cd-buttons" style="display: contents;">
                <li><a id="yesReroutebtn" onclick="change_dialog_destination()">OK</a></li>
                <li><a id="noReroutebtn" onclick="close_change_dialog_destination()">Cancel</a></li>
            </ul>
            <a href="#" id="closeReroutebtn" onclick="close_change_dialog_destination()"
                class="cd-popup-close img-replace"></a>
        </div>
    </div>


    <div id="elevator_dialog" class="change_dialog_class"
        style="margin: 10%;margin-top: 15% !important; width: 245px; visibility: hidden;">
        <div class="cd-popup-container">
            <div class="reroute_class" style="width: 61px;height: 10px;"></div>
            <p id="confirm1">Elevator Guidelines</p>
            <img src="./images/elevatordialog.jpg" style="width: 245px;border-radius: 13px;" />
            <br />
            <p>Go up Floor : 3 <i class="fa-solid fa-circle-up"></i> </p>
            <br />
            <ul class="cd-buttons" style="display: contents;">
                <li><a id="yesReroutebtn" style="width: 245px;background-color: #428bca !important;">OK</a></li>
            </ul>
            <!-- <a href="#" id="closeReroutebtn" onclick="close_change_dialog_destination()" class="cd-popup-close img-replace"></a> -->
        </div>
    </div>




    <div class="mapboxgl-ctrl-bottom-left">
        <div class="mapboxgl-ctrl mapboxgl-ctrl-group"
            style="background-color: transparent;box-shadow: none;margin-bottom: 372px;">
            <div id="userGuide" style="
            position: fixed;
    top: 40%;
    display: none;
    z-index: 5;
    box-shadow: 0 0 0 2px rgb(0 0 0 / 20%);
    margin: 4px;
    background-color: white;
    text-align: center;
    margin-left: 0px;
    border-radius: 4px;">

                <button style="border: 1px #c1c1c1 solid;
                  border: 1px #c1c1c1 solid;
                border-radius: 5px;
                left: 1.5%;
                width: 34px;
                background-image: url(./images/help.png);
                background-size: cover;
                height: 34px;" onclick="instructions();" class="support"></button>
                <p id="instructionsLabel" style="font-size: 10px; margin: 0 0 0px !important;
                font-weight: bold;">Help</p>

            </div>
        </div>
    </div>


    <div class="overlay"> </div>

    <div class="filter-container">
        <div class="category">
            <h3>Booth type</h3>
            <hr>
            <div class="options" id="type-options">
                <div class="option">Premiumshell Stands</div>
                <div class="option">Space Only Rentals</div>
                <div class="option">Pod Packages</div>
            </div>
        </div>
        <div class="category">
            <h3>Area Size</h3>
            <hr>
            <div class="options" id="areas">

            </div>
        </div>
        <div class="category">
            <h3>Price</h3>
            <hr>
            <div class="options" id="prices">

            </div>
            <div id="prices_slider" class="slider-container">
                <div class="slider-wrapper">
                  <div class="slider-labels">
                    <span style="background: #f0f0f0; padding: 0px 4px; font-weight: 300; font-size: 13px;" id="minValueLabel">AED 0</span>
                    <span id="value1Label">AED 25,024</span>
                    <span id="value2Label">AED 78,894</span>
                  </div>
                  <div class="slider">
                    <div class="ruler"></div>
                    <input type="range" id="range1" min="0" max="600000" step="1000" value="250024">
                    <input type="range" id="range2" min="0" max="600000" step="1000" value="408894">
                    <div class="slider-track"></div>
                  </div>
                  <div class="input-fields">
                    <div>
                      <label for="from">From (AED)</label>
                      <input type="number" id="from" value="25024">
                    </div>
                    <div>
                      <label for="to">To (AED)</label>
                      <input type="number" id="to" value="78894">
                    </div>
                  </div>
                  <button class="search-button">Search</button>
                </div>
              </div>
              
        </div>
        <button class="filter-btn">Filter Results</button>
    </div>

    <script>

const button = document.getElementById("selectedCategory");

// Optional: Add hover effect with JavaScript if additional control is needed
button.addEventListener("mouseenter", () => {
  // Custom hover logic (if necessary)
});

button.addEventListener("mouseleave", () => {
  // Custom leave logic (if necessary)
});

const range1 = document.getElementById("range1");
const range2 = document.getElementById("range2");
const value1Label = document.getElementById("value1Label");
const value2Label = document.getElementById("value2Label");
const fromInput = document.getElementById("from");
const toInput = document.getElementById("to");
const ruler = document.querySelector(".ruler");

// Function to generate ruler ticks
const generateRuler = () => {
  const min = 0;
  const max = 600000;
  const step = 200000;

  for (let i = min; i <= max; i += step / 4) {
    const mark = document.createElement("div");
    mark.classList.add("mark");
    if (i % step === 0) {
      mark.classList.add("major");

      // Add label for major marks
      const label = document.createElement("div");
      label.classList.add("label");
      label.textContent = `AED ${i.toLocaleString()}`;
      label.style.left = `${(i / max) * 100}%`;
      label.style.left = label.style.left - 4;
      ruler.appendChild(label);
    }
    mark.style.left = `${(i / max) * 100}%`;
    ruler.appendChild(mark);
  }
};

// Update slider functionality
const updateSlider = () => {
  const value1 = parseInt(range1.value);
  const value2 = parseInt(range2.value);

  // Ensure range1 stays below range2
  if (value1 > value2 - 1000) range1.value = value2 - 1000;
  if (value2 < value1 + 1000) range2.value = value1 + 1000;

  // Update labels and inputs
  value1Label.textContent = `AED ${parseInt(range1.value).toLocaleString()}`;
  value2Label.textContent = `AED ${parseInt(range2.value).toLocaleString()}`;
  fromInput.value = range1.value;
  toInput.value = range2.value;
};

// Event listeners for range and input
range1.addEventListener("input", updateSlider);
range2.addEventListener("input", updateSlider);

fromInput.addEventListener("input", (e) => {
  range1.value = e.target.value;
  updateSlider();
});

toInput.addEventListener("input", (e) => {
  range2.value = e.target.value;
  updateSlider();
});

// Initialize ruler and slider
generateRuler();
updateSlider();


// Navigation buttons hover effect
const navButtons = document.querySelectorAll(".nav-button");
        navButtons.forEach((button) => {
            button.addEventListener("mouseover", () => {
                button.style.transform = "translateY(-2px)";
            });
            button.addEventListener("mouseout", () => {
                button.style.transform = "translateY(0)";
            });
        });


        function toggle_card_fun() {
            const div = document.getElementsByClassName('card');
            div[0].style.opacity = '0'; // Fade out
            div[0].style.transform = 'translateX(-200px)'; // Move to the left

            if (routeEnabled) {
                var btn_show = document.getElementById("show_card_btn");
                btn_show.style.display = "block";

                var btn_distance = document.getElementById("btn_distance");
                btn_distance.style.display = "block";

                var btn_title = document.getElementById("btn_title");
                btn_title.style.display = "block";

                var btn_time = document.getElementById("btn_time");
                btn_time.style.display = "block";

                var btn_level = document.getElementById("btn_level");
                btn_level.style.display = "block";
            }
        }

        function show_dialog_card() {

            var btn_show = document.getElementById("show_card_btn");
            btn_show.style.display = "none";

            var btn_distance = document.getElementById("btn_distance");
            btn_distance.style.display = "none";

            var btn_title = document.getElementById("btn_title");
            btn_title.style.display = "none";

            var btn_time = document.getElementById("btn_time");
            btn_time.style.display = "none";

            var btn_level = document.getElementById("btn_level");
            btn_level.style.display = "none";

            document.getElementsByClassName("card")[0].style.display = "block";
            const div = document.getElementsByClassName('card');
            div[0].style.opacity = '1'; // Fade out
            div[0].style.transform = 'translateX(1px)';
        }

        var open_f = true;
        function open_filter() {
            if (open_f) {
                open_f = false;
                document.getElementsByClassName("filter-container")[0].style.display = "block";
                ClearRoute();
                var btn_show = document.getElementById("show_card_btn");
                btn_show.style.display = "none";

                var btn_distance = document.getElementById("btn_distance");
                btn_distance.style.display = "none";

                var btn_title = document.getElementById("btn_title");
                btn_title.style.display = "none";

                var btn_time = document.getElementById("btn_time");
                btn_time.style.display = "none";

                var btn_level = document.getElementById("btn_level");
                btn_level.style.display = "none";

                document.getElementsByClassName("card")[0].style.display = "none";

            } else {
                open_f = true;
                document.getElementsByClassName("filter-container")[0].style.display = "none";
            }
        }

        const areaOptions = {
            "Premiumshell Stands": ["9 SQM", "12 SQM", "15 SQM", "16 SQM", "18 SQM", "21 SQM"],
            "Space Only Rentals": ["25 SQM", "30 SQM", "40 SQM", "50 SQM", "80 SQM", "100 SQM", "200 SQM"],
            "Pod Packages": ["4 SQM", "6 SQM", "8 SQM"]
        };

        const priceOptions = {
            "Premiumshell Stands": {
                "9 SQM": "31,305 AED",
                "12 SQM": "40,920 AED",
                "15 SQM": "50,535 AED",
                "16 SQM": "53,740 AED",
                "18 SQM": "60,150 AED",
                "21 SQM": "69,765 AED"
            },
            "Space Only Rentals": {
                "25 SQM": "66,960 AED",
                "30 SQM": "79,860 AED",
                "40 SQM": "105,660 AED",
                "50 SQM": "131,460 AED",
                "80 SQM": "190,460 AED",
                "100 SQM": "260,460 AED",
                "200 SQM": "518,460 AED"
            },
            "Pod Packages": {
                "4 SQM": "8,580 AED",
                "6 SQM": "11,700 AED",
                "8 SQM": "14,700 AED"
            }
        };

        document.querySelectorAll('#type-options .option').forEach(option => {
            option.addEventListener('click', () => {
                // Remove "selected" class from all options in Type
                document.querySelectorAll('#type-options .option').forEach(opt => {
                    opt.classList.remove('selected');
                });
                // Add "selected" class to clicked option
                option.classList.add('selected');

                // Update Area options based on selected Type
                const selectedType = option.textContent;
                const areasContainer = document.getElementById('areas');
                areasContainer.innerHTML = ''; // Clear existing options
                const pricesContainer = document.getElementById('prices');
                pricesContainer.innerHTML = ''; // Clear existing price options

                if (areaOptions[selectedType]) {
                    areaOptions[selectedType].forEach(area => {
                        const areaDiv = document.createElement('div');
                        areaDiv.className = 'option';
                        areaDiv.textContent = area;
                        areaDiv.addEventListener('click', () => {
                            // Deselect other area options
                            document.getElementById("prices_slider").style.display = "block";
                            document.querySelectorAll('#areas .option').forEach(opt => {
                                opt.classList.remove('selected');
                            });
                            areaDiv.classList.add('selected');

                            // Update Prices based on Area selected
                            const selectedArea = areaDiv.textContent;
                            if (priceOptions[selectedType] && priceOptions[selectedType][selectedArea]) {
                                const price = priceOptions[selectedType][selectedArea];
                                const priceDiv = document.createElement('div');
                                priceDiv.className = 'option';
                                priceDiv.textContent = price;
                                pricesContainer.innerHTML = ''; // Clear previous prices
                                pricesContainer.appendChild(priceDiv);

                                // Add event listener to price option
                                priceDiv.addEventListener('click', () => {
                                    // Deselect all price options
                                    const number = priceDiv.innerText.replace(/[^0-9]/g, "");
                                    document.getElementById("to").value = number;
                                    
                                    document.getElementById("from").value = 0;
                                    // document.getElementById("from").value = parseInt(number - 1000);
                                    // document.getElementById("range1").value = parseInt(number - 1000);
                                    document.getElementById("range1").value = 0;

                                    document.getElementById("range2").value = number;

                                    // document.getElementById("value1Label").innerText = "AED "+ document.getElementById("from").value;
                                    document.getElementById("value1Label").innerText = "AED "+ 0;

                                    document.getElementById("value2Label").innerText = "AED "+ document.getElementById("to").value;

                                    document.querySelectorAll('#prices .option').forEach(opt => {
                                        opt.classList.remove('selected');
                                    });
                                    // Add "selected" class to clicked price option
                                    priceDiv.classList.add('selected');
                                });
                            }
                        });
                        areasContainer.appendChild(areaDiv);
                    });
                }
            });
        });

        // Handle Filter button click
        document.querySelector('.filter-btn').addEventListener('click', () => {
            open_f = true;
            document.getElementsByClassName("filter-container")[0].style.display = "none";
            const selectedType = document.querySelector('#type-options .option.selected')?.textContent || "None";
            const selectedArea = document.querySelector('#areas .option.selected')?.textContent || "None";
            const selectedPrice = document.querySelector('#prices .option.selected')?.textContent || "None";

            const selectedValues = [];

            // Add the values to the array only if they are not equal to "None"
            if (selectedType !== "None") {
                selectedValues.push(selectedType);
            }

            if (selectedArea !== "None") {
                selectedValues.push(selectedArea);
            }

            if (selectedPrice !== "None") {
                selectedValues.push(selectedPrice);
            }
            //alert(`Selected Type: ${selectedType}\nSelected Area: ${selectedArea}\nSelected Price: ${selectedPrice}`);

            highlightMatchingPolygons(selectedValues);
        });
        // document.querySelectorAll('#type-options .option').forEach(option => {
        //     option.addEventListener('click', () => {
        //         // Remove "selected" class from all options in this category
        //         document.querySelectorAll('#type-options .option').forEach(opt => {
        //             opt.classList.remove('selected');
        //         });
        //         // Add "selected" class to the clicked option
        //         option.classList.add('selected');
        //     });
        // });

        // // Allow multiple selections for other categories
        // document.querySelectorAll('#areas .option, #prices .option').forEach(option => {
        //     option.addEventListener('click', () => {
        //         option.classList.toggle('selected');
        //     });
        // });

        // // Handle Filter button click
        // document.querySelector('.filter-btn').addEventListener('click', () => {
        //     const selectedType = document.querySelector('#type-options .option.selected')?.textContent || "None";
        //     const selectedAreas = Array.from(document.querySelectorAll('#areas .option.selected')).map(opt => opt.textContent);
        //     const selectedPrices = Array.from(document.querySelectorAll('#prices .option.selected')).map(opt => opt.textContent);

        //     alert(`Selected Type: ${selectedType}\nSelected Areas: ${selectedAreas.join(', ')}\nSelected Prices: ${selectedPrices.join(', ')}`);
        // });

        var move_to_location_flag = false;

        function move_location() {
            move_to_location_flag = true;
        }

        // send access token to the nearest 
        mapboxgl.accessToken = 'pk.eyJ1Ijoibm1hY2NvdW50cyIsImEiOiJja2xhazRobjgzbDkxMm9xb2d3YmQ3d2s2In0.wGFavxo8mpa7OI_lEhYUow';

        var map = new mapboxgl.Map({
            container: 'map', // container ID
            style: 'mapbox://styles/nmaccounts/clwn3262a00ug01pn3ugm0an2',
            center: [55.28786820969455, 25.22390828178085], // starting position [lng, lat]
            pitch: 54.480589396819035,
            bearing: 34.23950142532499,
            zoom: 20
        });

        //         var Draw = new MapboxDraw();

        // // Map#addControl takes an optional second argument to set the position of the control.
        // // If no position is specified the control defaults to `top-right`. See the docs
        // // for more details: https://docs.mapbox.com/mapbox-gl-js/api/#map#addcontrol

        // map.addControl(Draw, 'top-left');

        // Mapbox Text Right to left - Support Arabic text.
        mapboxgl.setRTLTextPlugin(
            'https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-rtl-text/v0.2.3/mapbox-gl-rtl-text.js',
            null,
            true // Lazy load the plugin
        );

        function launch_toast() {
            var x = document.getElementById("toast")
            x.className = "show";
            var dec = document.getElementById("desc").innerHTML = "Parking location saved";
            setTimeout(function () { x.className = x.className.replace("show", ""); }, 5000);
        }


        // Add Zoom in & Zoom out & Compass control
        map.addControl(new mapboxgl.NavigationControl(), 'bottom-right');

        // $(document).ready(function () {
        //     $('.js-example-basic-single').select2();
        // });

        $(document).ready(function () {
            // $("#TO_Location").select2({
            //     matcher: matchCustom,
            //     templateResult: formatCustom
            // });
            $('#TO_Location').select2({
                templateResult: function (data) {
                    if (!data.id) {
                        return data.text; // Placeholder for empty selection
                    }

                    // Retrieve custom attributes
                    const img = $(data.element).data('img');
                    const foo = $(data.element).data('foo');
                    const title = data.text;

                    return $(`
            <div style="display: flex; align-items: center;">
                <img src="${img}" style="width: 50px; height: 50px; margin-right: 10px;" alt="Icon" />
                <div>
                    <div>${title}</div>
                    <small style="color: gray;">${foo}</small>
                </div>
            </div>
        `);
                },
                templateSelection: function (data) {
                    if (!data.id) {
                        return data.text;
                    }

                    // Retrieve attributes for the selected item
                    const img = $(data.element).data('img');
                    const title = data.text;

                    return $(`
            <span style="display: flex; align-items: center;">
                <img src="${img}" style="width: 20px; height: 20px; margin-right: 10px;" alt="Icon" />
                ${title}
            </span>
        `);
                }
            });
        });

        var modal = document.getElementById("myModal");

        var span = document.getElementsByClassName("close")[0];
        // When the user clicks on <span> (x), close the modal
        span.onclick = function () {
            modal.style.display = "none";
            ClearRoute();
        }


        function stringMatch(term, candidate) {
            return candidate && candidate.toLowerCase().indexOf(term.toLowerCase()) >= 0;
        }

        function matchCustom(params, data) {
            // If there are no search terms, return all of the data
            if ($.trim(params.term) === '') {
                return data;
            }
            // Do not display the item if there is no 'text' property
            if (typeof data.text === 'undefined') {
                return null;
            }
            // Match text of option
            if (stringMatch(params.term, data.text)) {
                return data;
            }
            // Match attribute "data-foo" of option
            if (stringMatch(params.term, $(data.element).attr('data-foo'))) {
                return data;
            }
            // Return `null` if the term should not be displayed
            return null;
        }

        function formatCustom(state) {
            return $(
                '<div><div>' + state.text + '</div><div class="foo">' +
                $(state.element).attr('data-foo') +
                '</div></div>'
            );
        }

        function test() {
            $("body").append("<span class ='toast'>parking location saved</span>");
            setTimeout(function () {
                $(".toast").remove();
            }, 3000);
        }


        //////////////////////////////////////////////////////////////// --- START --- /////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////// *** LOAD MAP Data : buildings, floors , POIs , Routes , Beacons , Triggers *** ///////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        // 0 - Variables 
        var global_name, global_distance, global_time, global_zlevel, global_icon;
        var floornametitle = []
        var Bearer_token, API_URL, cateogry_object, cateogry_array = {}, buildings_object, Floors_array = new Array(),
            flag_layer = true, toggleableLayerIds_counter = 0, floors_objects = new Array(), Floor_coordinates = new Array(),
            Layers_objects = new Array(), Level_route_poi, Level_Current_bluedot = 0, Poly_geojson_level, Poly_geojson_level_outsidebuilding, imageload_flag = true,
            Route_buildings = {}, points_route_object = new Array(), level_array = {}, pois_arr = new Array(), Layersnames = [], counter = 0,
            toggleableLayerIds = [], level_title, POI_counter = 0, language = "AR", denidlocations_AR = [], denidlocations_EN = [], routeEnabled = false,
            current_lvl = 0, elevator_level, elevators = new Array(), Routes_array = {}, graph = new Graph(), slct_marker, route_array = [], Route_by_level, Route_by_level_another, SmartRoute,
            isfirstt = true, entered = false, prevpoi, change_lg, change_lt, change_lvl, change_name, change_icon, change_selected_poi, is_marker_removed = false,
            cateogry_object, cateogry_array = {}, ins_lng = new Array(), ins_lat = new Array(), Route_ins = new Array(), prev_route_ins = new Array(),
            Route_ins_lgn = new Array(), Route_ins_lat = new Array(), blueDot, pointx, blue_lng, blue_lat, first_f, first_ff = true, prefloor, first_move = true, directions, ze = 0,
            beacon_floor_index, previns = "", found = 0, gate_lng = 46.59789940118716, gate_lat = 24.87748047220471, gate_lng_1 = 46.597893887143385, gate_lat_1 = 24.87748500001004;

        var buildingslayers = [
            turf.polygon([
                [
                    [55.28810996855265, 25.22647869954642],
                    [55.28617432251099, 25.223682097586703],
                    [55.28837335236511, 25.22234464709109],
                    [55.29049667068509, 25.2252146924169],
                    [55.28810996855265, 25.22647869954642]
                ]])
        ];

        var searchWithin = turf.polygon([[
            [55.28810996855265, 25.22647869954642],
            [55.28617432251099, 25.223682097586703],
            [55.28837335236511, 25.22234464709109],
            [55.29049667068509, 25.2252146924169],
            [55.28810996855265, 25.22647869954642]
        ]]);

        var BlueDot_location = {
            lng: 50.13566226981217, lat: 26.309483417773322
        };



        var Full_path_route = {
            'type': 'FeatureCollection',
            'features': [{
                'type': 'Feature',
                'geometry': {
                    'type': 'LineString',
                    'coordinates': []
                }
            }]
        };
        var english_levels = {
            "-5": "Basment 5th Floor",
            "-4": "Basment 4th Floor",
            "-3": "Basment 3rd Floor",
            "-2": "basment 2nd Floor",
            "-1": "Basment Floor",
            0: "Ground floor",
            1: "First Floor",
            2: "Second Floor",
            3: "Third Floor",
            4: "Fourth Floor",
            5: "Fifth Floor",
            6: "Sixth Floor",
            7: "Seventh Floor",
            8: "Eighth Floor",
            9: "Ninth Floor",
            10: "Tenth Floor"
        };
        var arabic_levels = {
            "-5": "Basment 5th Floor",
            "-4": "Basment 4th Floor",
            "-3": "Basment 3rd Floor",
            "-2": "basment 2nd Floor",
            "-1": "Basment Floor",
            0: "Ground floor",
            1: "First Floor",
            2: "Second Floor",
            3: "Third Floor",
            4: "Fourth Floor",
            5: "Fifth Floor",
            6: "Sixth Floor",
            7: "Seventh Floor",
            8: "Eighth Floor",
            9: "Ninth Floor",
            10: "Tenth Floor"

        };

        var All_POI_object = {
            'type': 'FeatureCollection',
            'features': [{
                'id': "",
                'type': 'Feature',
                'geometry': {
                    'type': "Polygon",
                    'coordinates': []
                },
                'properties': {
                    'title': '',
                    'icon': "",
                    'subtitles': [],
                    "Center": []
                }
            }]
        };


        function get_Authentication() {
            var settings = {
                "url": "https://api.nearmotion.com/api/public/v1/saas_companies/Abu%20Test/oauth/token",
                "method": "POST",
                "timeout": 0,
                "headers": {
                    "Content-Type": "application/json",
                    "accept": "application/json"
                },
                "data": JSON.stringify({
                    "client_id": "8FArG1hUlSujXC1O3moYU-FrjX_UVwcAt-SOHOniG04",
                    "client_secret": "Ojido9vxKlx-U33PhKGfOB4uwAsOOtRW9uF_ZeCJvMY",
                    "grant_type": "password",
                    "user_id": "abubaker@nearmotion.com",
                    "os": "ios",
                    "environment": "sandbox",
                    "push_token": "string"
                }),
            };

            $.ajax(settings).done(function (response) {
                Bearer_token = response.access_token;
                open_map(Bearer_token, "https://api.nearmotion.com/api/public/v1/");
                get_category(Bearer_token);
            });
        }

        var entered_category = true;

        // 2 - get category API.
        async function get_category(token) {
            if (entered_category) {
                var xhr = new XMLHttpRequest();
                xhr.addEventListener("readystatechange", function () {
                    if (this.readyState == 4) {
                        cateogry_object = JSON.parse(this.responseText);
                        var category_length =
                            cateogry_object.building_poi_categories.length;
                        for (
                            var a = 0;
                            a <
                            cateogry_object.building_poi_categories.length;
                            a++
                        ) {
                            cateogry_array[
                                cateogry_object.building_poi_categories[
                                    a
                                ].id
                            ] =
                                cateogry_object.building_poi_categories[
                                    a
                                ].name;
                            if (
                                cateogry_array[
                                    cateogry_object.building_poi_categories[
                                        a
                                    ].id
                                ] != "All" &&
                                cateogry_array[
                                    cateogry_object.building_poi_categories[
                                        a
                                    ].id
                                ] != "Test"
                            ) {
                                $("#scrollmenu").append(
                                    $(
                                        "<button id='selectedCategory' onclick='filter_Results(this)' class='nav-button nav_cat'>" +
                                            cateogry_object
                                                .building_poi_categories[a]
                                                .name +
                                            "</button>"
                                    )
                                );
                            }
                        }
                    }
                });
                xhr.open(
                    "GET",
                    "https://api.nearmotion.com/api/public/v1/building_poi_categories"
                );
                xhr.setRequestHeader("Authorization", "Bearer " + token);
                xhr.setRequestHeader("accept", "application/json");
                xhr.setRequestHeader(
                    "Content-Encoding",
                    "gzip,deflate, br"
                );
                xhr.send();
                entered_category = false;
            }

            setTimeout(() => {
                $(".nav_cat").each(function () {
                    originalText = $(this).text();
                    $(this).attr("data-original-text", originalText);
                });
            }, 1000);
        }

            function filter_Results(e) {
                $('#TO_Location').empty()
                $('#TO_Location').append($("<option></option>"));
                if(e.innerHTML != 'All' ){
                    dropdownlist_filter(e.innerHTML);
                    highlightMatchingPolygons_filterdop(e.innerHTML);
                }else{
                    clear_filter();
                    dropdownlist_filter_all(e.innerHTML);
                }
			}

        
            function highlightMatchingPolygons_filterdop(e) {
            clear_filter();
            const features = map.getSource("municipalities")._data.features;
            features.forEach((feature) => {
                const category_id = feature.properties.category_id;
                if(category_id != null){
                if (cateogry_array[category_id] == e) {
                    var match =  true;
                    map.setFeatureState(
                        { source: 'municipalities', id: feature.id },
                        { selected: match }
                    );
                }
                }
            });

        }


        function dropdownlist_filter(cateogry)
        {
            for(var x = 0 ; x < All_POI_object.features.length ; x++){
                var poi = All_POI_object.features[x].properties;
              if(cateogry != "All" && poi.category_id != null ){
                if (!denidlocations_AR.includes(poi.title) && poi.title != "room" && poi.title != "xx" && cateogry_array[poi.category_id] == cateogry) {
                    var level = poi.Level ;
                    var category_ar = "GISEC - "+get_terminal_name(parseFloat(poi.Center[0]) , parseFloat(poi.Center[1]))+" - ";
                    level = arabic_levels[level];
                    if (poi.category_id != null) {
                        category_ar = cateogry_array[poi.category_id] + " - "+get_terminal_name(parseFloat(poi.Center[0]) , parseFloat(poi.Center[1]))+" - ";
                    }
                    var icon_url = "";
                    if ('icon' in poi) {
                        icon_url = poi.icon_url;
                    }
                    if(icon_url == '')
                    {
                        icon_url = "./images/location.png" 
                    }
                    // else {
                    //     icon_url = "./images/location.png"
                    // }
                    $('#TO_Location')
                        .append($("<option>")
                            .attr("data-foo", category_ar + " " + level)
                            .attr("data-img", icon_url)
                            .attr("value", poi.longitude + "," + poi.latitude + "," + poi.building_floor_id)
                            .text(poi.title)
                        );
                }
              }
            }
        }

        function dropdownlist_filter_all(cateogry)
        {
            for(var x = 0 ; x < All_POI_object.features.length ; x++){
                var poi = All_POI_object.features[x].properties;
                if (!denidlocations_AR.includes(poi.title) && poi.title != "room" && poi.title != "xx" && poi.title != "") {
                    var level = poi.Level;
                    var category_ar = "GISEC - "+get_terminal_name(parseFloat(poi.Center[0]) , parseFloat(poi.Center[1]))+" - ";
                    level = arabic_levels[level];
                    if (poi.category_id != null) {
                        category_ar = cateogry_array[poi.category_id] + " - "+get_terminal_name(parseFloat(poi.Center[0]) , parseFloat(poi.Center[1]))+" - ";
                    }
                    var icon_url = "";
                    if ('icon' in poi) {
                        icon_url = poi.icon_url;
                    }
                    if(icon_url == '')
                    {
                        icon_url = "./images/location.png" 
                    }
                    // else {
                    //     icon_url = "./images/location.png"
                    // }
                    $('#TO_Location')
                        .append($("<option>")
                            .attr("data-foo", category_ar + " " + level)
                            .attr("data-img", icon_url)
                            .attr("value", poi.longitude + "," + poi.latitude + "," + poi.building_floor_id)
                            .text(poi.title)
                        );
                }
              
            }
        }
            async function Load_data_drop_language_category(category_id) {
				// $("#TO_Location").append($("<option data-foo=''></option>"));
				if (language == "EN") {
					var size = All_POI_object.features.length;
					for (var i = 0; i < size; i++) {
						if (
							All_POI_object.features[i].properties.category_id ==
							category_id
						) {
							let temp = All_POI_object.features[i];
							for (keys in All_POI_object.features[i].properties)
								temp[keys] =
									All_POI_object.features[i].properties[keys];

							load_english(temp);
						}
					}
				} else if (language == "AR") {
					var size = All_POI_object.features.length;
					for (var i = 0; i < size; i++) {
						if (
							All_POI_object.features[i].properties.category_id ==
							category_id
						) {
							let temp = All_POI_object.features[i];
							for (keys in All_POI_object.features[i].properties)
								temp[keys] =
									All_POI_object.features[i].properties[keys];

							load_arbic(temp);
						}
					}
				}
                //  else {
				// 	var size = All_POI_object.features.length;
				// 	for (var i = 0; i < size; i++) {
				// 		if (
				// 			All_POI_object.features[i].properties.category_id ==
				// 			category_id
				// 		) {
				// 			let temp = All_POI_object.features[i];
				// 			for (keys in All_POI_object.features[i].properties)
				// 				temp[keys] =
				// 					All_POI_object.features[i].properties[keys];

				// 			load_chinese(temp);
				// 		}
				// 	}
				// }
			}


        // document.addEventListener("click", (e) => {

		// 		if (
		// 			(!searchBar.contains(e.target) &&
		// 				!$("#scrollmenu")[0].contains(e.target)) ||
		// 			(searchBar.contains(e.target) &&
		// 				searchBar.classList.contains("active"))
		// 		) {
		// 			searchBar.classList.remove("active");
		// 			searchDropdown.classList.remove("active");
		// 			searchInput.blur();
		// 		} else if (searchBar.contains(e.target)) {
		// 			searchInput.focus();
		// 			searchBar.classList.add("active");
		// 			searchDropdown.classList.add("active");
		// 		}
		// 	});

        var qaribToken = "";
        function get_Authentication2() {
            var url = "https://qarib.nearmotion.com/saas_companies/jhah/api/v1/oauth/token";

            var xhr = new XMLHttpRequest();
            xhr.open("POST", url);

            xhr.setRequestHeader("Content-Type", "application/json");

            xhr.onreadystatechange = function () {
                if (xhr.readyState === 4) {

                }
            };

            var data = '{"client_id":"e3pbbulNAV3knMlAtIYzIOWRh-Dpz2WpabDk6lqiUIc","client_secret":"9onjnvf_wcJGTk7SMsFAbHNHwlcLhXqouOR9fCgwfbo","grant_type":"password","user_id":"string","os":"ios","environment":"sandbox"}';

            xhr.send(data);
        }

        $("#TO_Location").change(function () {
            select_dropdown_list_item();
        });

        function get_poi_ob(poi_name)
        {
            for(var m = 0 ; m < All_POI_object.features.length ; m++)
            {
                if(poi_name == All_POI_object.features[m].properties.title)
                {
                    return All_POI_object.features[m];
                }
            }
        }

        function select_dropdown_list_item() {

            var To = document.getElementById("TO_Location");
            var Location_end_ = To.options[To.selectedIndex].value;
            var sel = document.getElementById("TO_Location");
            var to_coordinates = Location_end_.split(',');
            var poi_name = sel.options[sel.selectedIndex].text;
            var xx = get_poi_ob(poi_name);
            document.getElementsByClassName("filter-container")[0].style.display = "none";
            const clickedRoomId = xx.id;
            poi_id = xx.id;
            journy_info(global_name, global_distance, global_time, global_zlevel, global_icon);
            if (lastClickedRoomId !== null && lastClickedRoomId !== clickedRoomId) {
                map.setFeatureState(
                    { source: 'municipalities', id: lastClickedRoomId },
                    { selected: false }
                );
            }

            // Highlight the currently clicked feature
            map.setFeatureState(
                { source: 'municipalities', id: clickedRoomId },
                { selected: true }
            );

            // Update the last clicked room id
            lastClickedRoomId = clickedRoomId;



            // for(var x = 0 ; x < All_POI_object.features.length ; x++)
            // {
            //     if(clickedRoomId == All_POI_object.features[x].id)
            //     {
            //         //console.log(All_POI_object.features[x].geometry.coordinates);
            //         //get_area(All_POI_object.features[x].geometry.coordinates);
            //         if(All_POI_object.features[x].properties.subtitles.length > 0)
            //         {
            //             console.log("Area : "+All_POI_object.features[x].properties.subtitles[0]+" meters");
            //         }
            //     }
            // }


            var sub = xx.properties.subtitles;

            document.getElementsByClassName("card")[0].style.display = "block";
            const div = document.getElementsByClassName('card');
            div[0].style.opacity = '1'; // Fade out
            div[0].style.transform = 'translateX(1px)';

            var btn_show = document.getElementById("show_card_btn");
            btn_show.style.display = "none";

            if (xx.properties.icon_url != '') {
                document.getElementById("img_card").src = xx.properties.icon_url;
            } else {
                if (xx.properties.title == "") {
                    document.getElementById("img_card").src = './images/booking.png';
                } else {
                    document.getElementById("img_card").src = './images/gisec.jpg';
                }
            }

            if (xx.properties.title != '') {
                var sub = xx.properties.subtitles;
                document.getElementById("title_card").innerHTML = xx.properties.title;
            }
            else {
                if (sub.length > 0) {
                    document.getElementById("title_card").innerHTML = "Booth Type : " + sub[0];
                } else {
                    document.getElementById("title_card").innerHTML = "Booth";
                }
            }

            

            if (sub.length > 1) {
                if (!sub[1].includes("SQM")) {
                    document.getElementById("desc_card").innerHTML = sub[1];
                } else {
                    document.getElementById("desc_card").innerHTML = "Area Size : " + sub[1] + " , Price : " + sub[2];
                }

            } else {
                document.getElementById("desc_card").innerHTML = "";
            }

            if (xx.properties.title.length == 0) {
                var poi_name = "Booth";
                document.getElementById("book_btn").style.visibility = "visible";
            } else {
                var poi_name = xx.properties.title;
                document.getElementById("book_btn").style.visibility = "hidden";

            }

            var lg = xx.properties.Center[0];
            var lt = xx.properties.Center[1];
            var lvl = xx.properties.Level;
            var icon_url = xx.properties.icon_url;
            var selected_poi = xx;

            document.getElementById("hall_no").innerHTML = get_terminal_name(parseFloat(lg), parseFloat(lt));

            
            change_lg = lg;
            change_lt = lt;
            change_name = poi_name;
            change_lvl = lvl;
            change_icon = icon_url;
            change_selected_poi = selected_poi;


            // var lg = to_coordinates[0];
            // var lt = to_coordinates[1];
            // var lvl = level_array[parseInt(to_coordinates[2])];
            // var icon_url = "";
            // var selected_poi = {
            //     'type': 'FeatureCollection',
            //     'features': [{
            //         'type': 'Feature',
            //         'geometry': {
            //             'type': 'LineString',
            //             'coordinates': []
            //         }
            //     }]
            // };

            // change_lg = lg;
            // change_lt = lt;
            // change_name = poi_name;
            // change_lvl = lvl;
            // change_icon = icon_url;
            // change_selected_poi = selected_poi;

            // draw_path_to_poi(poi_name, lg, lt, lvl, icon_url, selected_poi);

            // if (routeEnabled) {

            //     document.getElementById("change_dialog").style.visibility = "visible";
            //     $('.cd-popup-trigger').on('click', function (event) {
            //         event.preventDefault();
            //         $('.cd-popup').addClass('is-visible');
            //     });

            //     $('.cd-popup').on('click', function (event) {
            //         $('.cd-popup').removeClass('is-visible');
            //         document.getElementById('change_dialog').style.visibility = "hidden";
            //     });
            //     $(document).keyup(function (event) {
            //         if (event.which == '27') {
            //             $('.cd-popup').removeClass('is-visible');
            //             document.getElementById('change_dialog').style.visibility = "hidden";
            //         }
            //     });
            // }
            // else {
            //     draw_path_to_poi(poi_name, lg, lt, lvl, icon_url, selected_poi);
            // }
        }

        // 1 - open map
        async function open_map(token_test, url) {

            // Layers_objects = JSON.parse(fixed_layers);
            //sortedInput = Layers_objects;
            //add layers to map
            // layers_level(sortedInput);

            Bearer_token = token_test;
            API_URL = url;
            // 2 - Fetch Category API.
            //get_category(Bearer_token);
            // 3 - get building
            get_building(Bearer_token);
        }


        // async function get_category(token) {
        //     var xhr = new XMLHttpRequest();
        //     xhr.addEventListener("readystatechange", function () {
        //         if (this.readyState == 4) {
        //             cateogry_object = JSON.parse(this.responseText);
        //             for (var a = 0; a < cateogry_object.building_poi_categories.length; a++) {
        //                 cateogry_array[cateogry_object.building_poi_categories[a].id] = cateogry_object.building_poi_categories[a].name;
        //             }
        //             localStorage.setItem("cateogry", JSON.stringify(cateogry_array));
        //         }
        //     });
        //     xhr.open("GET", API_URL + "building_poi_categories");
        //     xhr.setRequestHeader("Authorization", "Bearer " + token);
        //     xhr.setRequestHeader("accept", "application/json");
        //     xhr.setRequestHeader("Content-Encoding", "gzip,deflate, br");
        //     xhr.send();
        // }

        // 2 - get category API.
        // async function get_category(token) {
        //     var xhr = new XMLHttpRequest();
        //     xhr.addEventListener("readystatechange", function () {
        //         if (this.readyState == 4) {
        //             cateogry_object = JSON.parse(this.responseText);
        //             var category_length = cateogry_object.building_poi_categories.length;
        //             for (var a = 0; a < category_length; a++) {
        //                 cateogry_array[cateogry_object.building_poi_categories[a].id] = cateogry_object.building_poi_categories[a].name;
        //             }
        //             localStorage.setItem("cateogry", JSON.stringify(cateogry_array));
        //         }
        //     });
        //     xhr.open("GET", API_URL + "building_poi_categories");
        //     xhr.setRequestHeader("Authorization", "Bearer " + token);
        //     xhr.setRequestHeader("accept", "application/json");
        //     xhr.setRequestHeader("Content-Encoding", "gzip,deflate, br");
        //     xhr.send();
        // }

        // 3 - get buildings function
        async function get_building(Bearer_token) {
            buildings_object = JSON.parse(await get_buildings(Bearer_token));
            //buildings_object = JSON.parse(fixed_building);
            //set map center to building's location.
            // map.flyTo({
            //     center: [buildings_object.buildings[0].coordinate.longitude, buildings_object.buildings[0].coordinate.latitude],
            //     zoom: 17.489296826958224,
            // });
            // map.setCenter([buildings_object.buildings[0].coordinate.longitude, buildings_object.buildings[0].coordinate.latitude]);
            map.setZoom(17.489296826958224);
            // blueDot.setLngLat({
            //     lng: buildings_object.buildings[0].coordinate.longitude,
            //     lat: buildings_object.buildings[0].coordinate.latitude
            // }, {
            //     animate: true,
            //     duration: 500
            // });
            Load_map_data();
        }

        async function get_buildings(token) {
            var xhr = new XMLHttpRequest();
            var z;
            xhr.open("GET", API_URL + "buildings", false);
            xhr.setRequestHeader("Authorization", "Bearer " + token);
            xhr.setRequestHeader("accept", "application/json");
            xhr.setRequestHeader("Content-Encoding", "gzip,deflate, br");
            xhr.onload = function (e) {
                z = xhr.responseText;
            };
            xhr.onerror = function () {

                resolve(undefined);
                console.error("An error occurred during the XMLHttpRequest");
            };
            xhr.send();
            return z;
        }
        var outside_coordinates; var journy_outside_info;
        async function get_outside_route(lng, lat) {
            // Separate the radiuses with semicolons

            // Weather Creditenal.
            const profile = "pk.eyJ1Ijoibm1hY2NvdW50cyIsImEiOiJja2xhazRobjgzbDkxMm9xb2d3YmQ3d2s2In0.wGFavxo8mpa7OI_lEhYUow";
            const cur_lng = blueDot.getLngLat().lng;
            const cur_lat = blueDot.getLngLat().lat;
            // Create the query
            const query = await fetch
                (
                    `https://api.mapbox.com/directions/v5/mapbox/driving/${cur_lng},${cur_lat};${lng},${lat}?approaches=unrestricted;curb&geometries=geojson&steps=true&access_token=${mapboxgl.accessToken}`,
                    {
                        method: 'GET'
                    }
                );
            const response = await query.json();
            // Handle errors
            if (response.code !== 'Ok') {
                console.log(`${response.code} - ${response.message}.\n\nFor more information: https://docs.mapbox.com/api/navigation/map-direction/#map-direction-api-errors`);
                return;
            }
            // Get the coordinates from the response
            const coords = response.routes[0].geometry;
            journy_outside_info = response.routes[0];
            outside_coordinates = coords;
        }

        function addRoute(coords) {
            // If a route is already loaded, remove it
            if (map.getSource('route')) {
                map.removeLayer('route');
                map.removeSource('route');
            } else {
                // Add a new layer to the map
                map.addLayer({
                    id: 'route',
                    type: 'line',
                    source: {
                        type: 'geojson',
                        data: {
                            type: 'Feature',
                            properties: {},
                            geometry: coords
                        }
                    },
                    layout: {
                        'line-join': 'round',
                        'line-cap': 'round'
                    },
                    paint: {
                        'line-color': '#03AA46',
                        'line-width': 8,
                        'line-opacity': 0.8
                    }
                });
            }
        }

        async function getMatch(coordinates, radius, profile) {
            // Separate the radiuses with semicolons
            const radiuses = radius.join(';');
            // Create the query
            const query = await fetch(
                `https://api.mapbox.com/matching/v5/mapbox/${profile}/${coordinates}?geometries=geojson&radiuses=${radiuses}&steps=true&access_token=${mapboxgl.accessToken}`,
                { method: 'GET' }
            );
            const response = await query.json();
            // Handle errors
            if (response.code !== 'Ok') {
                alert(
                    `${response.code} - ${response.message}.\n\nFor more information: https://docs.mapbox.com/api/navigation/map-matching/#map-matching-api-errors`
                );
                return;
            }
            // Get the coordinates from the response
            const coords = response.matchings[0].geometry;
            // Draw the route on the map
            addRoute(coords);
        }

        // 4 - Load map data floors : layers , routes , POIs , beacons , Triggers.
        async function Load_map_data() {
            // load floors
            get_floor_json();
            //floors_objects = JSON.parse(fixed_floors);
            // call start map load layers , POIS , route & triggers
            startmap();
            //load beacons
            //await get_beacons_json();
        }


        // 5 - Load Floors
        async function get_floor_json() {
            buildings_length = buildings_object.buildings.length;
            for (var x = 0; x < buildings_length; x++) {
                // 6 - call get floor API.
                get_floor(Bearer_token, buildings_object.buildings[x].id);
            }
        }

        floors_objects = new Array();
        // 6 - Function get floor API
        async function get_floor(token, building_id) {

            var xhr = new XMLHttpRequest();
            xhr.addEventListener("loadend", function () {
                if (this.readyState == 4) {
                    floors_objects.push(JSON.parse(this.responseText));
                }
            });
            xhr.open("GET", API_URL + "buildings/" + building_id + "/floors", false);
            xhr.setRequestHeader("Authorization", "Bearer " + token);
            xhr.setRequestHeader("accept", "application/json");
            xhr.setRequestHeader("Content-Encoding", "gzip,deflate, br");
            xhr.send();
        }

        // switch to floor on load 
        function switch_to_floor() {
            var noground = false;
            var menu = document.getElementById("menu");
            for (var i = 0; i < menu.childElementCount; i++) {
                if (menu.childNodes[i].innerText == "G") {
                    menu.childNodes[i].className = "active";
                    menu.children[i].click();
                    noground = true;
                }
                if (i == (menu.childElementCount - 1) && !noground) {
                    menu.childNodes[menu.childElementCount - 1].className = "active";
                    menu.children[menu.childElementCount - 1].click();
                    current_lvl = parseFloat(menu.children[menu.childElementCount - 1].innerText);
                }
            }
        }



        // 7 - Start map function 
        async function startmap() {
            // 8 - Floor layers API
            Load_Layer_data();
            // sort layers by floor id
            // Layers_objects = JSON.parse(fixed_layers);
            sortedInput = Layers_objects;
            // //add layers to map
            layers_level(sortedInput);
            //load POIs for each floor.
            load_pois_floors(sortedInput);

            // for (var i = 0; i < sortedInput.length; i++) {
            //     var b_id = sortedInput[i].building_floor.building_id;
            //     var f_id = sortedInput[i].building_floor.id;
            //     get_beacons_v2(Bearer_token, 1, b_id, f_id, true);
            // }
            // trigger();
            await route();
            blueDot_initilization();
            setTimeout(() => {
                map.moveLayer('polygons', 'mm-bluedot-accuracy1');
                map.moveLayer('pointx', 'mm-bluedot-accuracy1');
                map.moveLayer('polygons_outline', 'mm-bluedot-accuracy1');


                // map.addSource('static-image', {
                //     type: 'image',
                //     url: 'https://d1m6d407onyqpz.cloudfront.net/rails/active_storage/blobs/proxy/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBclI3IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--788edda63e98dca06c16929c2f9d775a685a0f92/GISSECImage.JPG',
                //     coordinates: JSON.parse(raster_images).features[0].geometry.coordinates[0]
                // });

                // map.addSource("imageraster", {
                //     type: "geojson",
                //     data: JSON.parse(raster_images),
                // });


                map.addSource('static-image', {
                    type: 'image',
                    url: 'https://d1m6d407onyqpz.cloudfront.net/rails/active_storage/blobs/proxy/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBclI3IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--788edda63e98dca06c16929c2f9d775a685a0f92/GISSECImage.JPG',
                    coordinates: [
                        [55.28824868495141, 25.2249989167789], // Bottom left (longitude, latitude)
                        [55.289421700161455, 25.224351962558018], // Bottom right
                        [55.28886730652752, 25.22354661229521], // Top right
                        [55.28770011214067, 25.22420300797407]  // Top left

                    ]
                });

                map.addLayer({
                    id: 'static-image-layer',
                    type: 'raster',
                    source: 'static-image'
                });

                map.addSource('Hall1', {
                    type: 'image',
                    url: 'https://d1m6d407onyqpz.cloudfront.net/rails/active_storage/blobs/proxy/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBbUI5IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--7541e1a25edeef01dd4658123d40e3bf0fb6dae3/Hall%201-squared.png',
                    coordinates: [
                        [55.287988400773145,  25.226200387688905], // Bottom left (longitude, latitude)
                        [55.28787887397476,  25.226042228916583], // Bottom right
                        [55.287697950579144,  25.226144342053118], // Top right
                        [55.28780543725185,  25.226303417863406]  // Top left

                    ]
                });
                map.addLayer({
                    id: 'Hall1',
                    type: 'raster',
                    source: 'Hall1'
                });



                map.addSource('Hall2', {
                    type: 'image',
                    url: 'https://d1m6d407onyqpz.cloudfront.net/rails/active_storage/blobs/proxy/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBbU45IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--4b3ec562a9ef10325f81823122bb74d54a6785a1/Hall%202-squared.png',
                    coordinates: [
                        [55.287612848246795,  25.225693870841596], // Bottom left (longitude, latitude)
                        [55.28750406342024,  25.225536591682243], // Bottom right
                        [55.287323658620124,  25.225637240495104], // Top right
                        [55.287429773909736,  25.225796569508447]  // Top left

                    ]
                });
                map.addLayer({
                    id: 'Hall2',
                    type: 'raster',
                    source: 'Hall2'
                });



                map.addSource('Hall3', {
                    type: 'image',
                    url: 'https://d1m6d407onyqpz.cloudfront.net/rails/active_storage/blobs/proxy/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBbVo5IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--def7479ea708c8d794117c189ef54d664080827c/Hall%203-squared.png',
                    coordinates: [
                        [55.2872448923919,  25.22511303432617], // Bottom left (longitude, latitude)
                        [55.28713710241556,  25.224954227981783], // Bottom right
                        [55.28695572184793,  25.225056629421545], // Top right
                        [55.2870641569958,  25.225215337598698]  // Top left

                    ]
                });
                map.addLayer({
                    id: 'Hall3',
                    type: 'raster',
                    source: 'Hall3'
                });



                map.addSource('Hall4', {
                    type: 'image',
                    url: 'https://d1m6d407onyqpz.cloudfront.net/rails/active_storage/blobs/proxy/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBbWg5IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--3feb282a65f12bbacb78c4103007f9c877ff6432/Hall%204-squared.png',
                    coordinates: [
                        [55.28688850301185,  25.224613253303318], // Bottom left (longitude, latitude)
                        [55.28678046916002,  25.224455352670603], // Bottom right
                        [55.28659691459197,  25.224557216315944], // Top right
                        [55.28670447533,  25.224716554090392]  // Top left
                    ]
                });
                map.addLayer({
                    id: 'Hall4',
                    type: 'raster',
                    source: 'Hall4'
                });


                map.addSource('Hall5', {
                    type: 'image',
                    url: 'https://d1m6d407onyqpz.cloudfront.net/rails/active_storage/blobs/proxy/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBbXA5IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--e634a74fc6f39281e41ab9b70285b2728ffc9728/Hall%205-squared.png',
                    coordinates: [
                        [55.286705359329574,  25.223478977224588], // Bottom left (longitude, latitude)
                        [55.286883245451264,  25.223376804678935], // Bottom right
                        [55.28678009519069,  25.2232168987518], // Top right
                        [55.28659643071862,  25.223318779257525]  // Top left
                    ]
                });
                map.addLayer({
                    id: 'Hall5',
                    type: 'raster',
                    source: 'Hall5'
                });


                map.addSource('Hall6', {
                    type: 'image',
                    url: 'https://d1m6d407onyqpz.cloudfront.net/rails/active_storage/blobs/proxy/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBbXg5IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--d1066d85df7eeffd2afcbcc0d6d0503db95c75e1/Hall%206-squared.png',
                    coordinates: [
                        [55.2870198029743,  25.22330117641968], // Bottom left (longitude, latitude)
                        [55.287200124312164,  25.22320007388555], // Bottom right
                        [55.28709394537472,  25.22303947103515], // Top right
                        [55.286910618947076,  25.22314154358922]  // Top left
                    ]
                });
                map.addLayer({
                    id: 'Hall6',
                    type: 'raster',
                    source: 'Hall6'
                });


                map.addSource('Hall7', {
                    type: 'image',
                    url: 'https://d1m6d407onyqpz.cloudfront.net/rails/active_storage/blobs/proxy/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBbkY5IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--53f4e69ddc892360bde6bf89233170e1eb450445/Hall%2077-squared.png',
                    coordinates: [
                        [55.28751691842871,  25.223012899586237], // Bottom left (longitude, latitude)
                        [55.28769388770485,  25.222910031603305], // Bottom right
                        [55.28758964192227,  25.222752559034873], // Top right
                        [55.287406299599326,  25.222852454630683]  // Top left
                    ]
                });
                map.addLayer({
                    id: 'Hall7',
                    type: 'raster',
                    source: 'Hall7'
                });


                map.addSource('Hall8', {
                    type: 'image',
                    url: 'https://d1m6d407onyqpz.cloudfront.net/rails/active_storage/blobs/proxy/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBbTk5IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--988eb6e074a95616f16c9a47962a091443455b0e/Hall%208-squared.png',
                    coordinates: [
                        [55.288018840451684,  25.222720151060187], // Bottom left (longitude, latitude)
                        [55.28819738696603,  25.222617934036748], // Bottom right
                        [55.288093846149195,  25.222458122817685], // Top right
                        [55.28791203580357,  25.2225589401325]  // Top left
                    ]
                });
                map.addLayer({
                    id: 'Hall8',
                    type: 'raster',
                    source: 'Hall8'
                });



                

            }, 1000);
        }



        var page_flag_2 = true;
        var counter_beacons = -1;
        var total_page_2;
        var Beacons_objects = new Array();

        async function getb(token, next, bui_id, flor_id, flag) {
            get_beacons_v2(token, next, bui_id, flor_id, flag);
        }

        async function start_beacons() {
            try {
                // window.interface.Beacons_jsons(Beacons_objects[counter_beacons]);
                //console.log(JSON.parse(Beacons_objects[counter_beacons]))
            }
            catch (err) {
                console.log(err);
            }
        }
        var resx;
        async function get_beacons_v2(token, next, building_id, floor_id, flag) {
            var xhr = new XMLHttpRequest();
            xhr.addEventListener("readystatechange", function () {
                if (this.readyState == 4) {

                    counter_beacons++;
                    Beacons_objects.push(this.responseText);
                    total_page_2 = this.getResponseHeader("x-pager-total-pages");
                    next = this.getResponseHeader("x-pager-next-page");
                    if (next == "") {
                        next = total_page_2;
                    }
                    if (next <= total_page_2 && flag) {
                        if (next == total_page_2) {
                            flag = false;
                        }
                        start_beacons();
                        // getb(token, next, building_id, floor_id, flag);

                    } else {
                        start_beacons();
                    }
                }
            });

            xhr.open("GET", API_URL + "buildings/" + building_id + "/floors/" + floor_id + "/beacons?page%5Bnumber%5D=" + next + "&page%5Bsize%5D=700");
            xhr.setRequestHeader("Authorization", "Bearer " + token);
            xhr.setRequestHeader("accept", "application/json");
            xhr.setRequestHeader("Content-Encoding", "gzip,deflate, br");
            xhr.send();
        }



        function blueDot_initilization() {

            var fake_data = {
                "type": "FeatureCollection",
                "features": [{
                    "type": "Feature",
                    "geometry": {
                        "type": "Point",
                        "coordinates": []
                    },
                    "properties": {
                        "heading": 0
                    }
                }]
            };

            map.addSource("Basement_points-9iik2n", {
                "type": "vector",
                "url": 'https://docs.mapbox.com/mapbox-gl-js/assets/earthquakes.geojson'
            });
            map.addLayer({
                'id': 'mm-poi-label',
                'type': 'symbol',
                'source': 'Basement_points-9iik2n',
                'source-layer': 'Basement_points-9iik2n',
                'layout': {
                    'visibility': 'none',
                    'text-field': ['get', 'Name'],
                    "symbol-placement": "point",
                    // 'text-variable-anchor': ['top', 'bottom', 'left', 'right'],
                    'text-radial-offset': 0.5,
                    'text-justify': 'auto',
                    'text-size': 12,
                    'text-font': [
                        'literal',
                        ['Arial Unicode MS Regular']
                    ],
                    "text-max-angle": 145,
                    'icon-image': 'cat',
                    'icon-size': 0.09
                },
                "paint": {
                    // 'font-scale': 0.8,
                    "text-color": "black",
                    "text-halo-color": "#fff",
                    "text-halo-width": 1
                },
            });

            BlueDot_location = { lng: parseFloat(buildings_object.buildings[0].coordinate.longitude), lat: parseFloat(buildings_object.buildings[0].coordinate.latitude) }
            //BlueDot_location = { lng: 46.70080831348737 , lat : 24.74144402972901 };

            blueDot = new Mazemap.BlueDot({
                accuracyCircle: true
            }).setLngLat(BlueDot_location).setAccuracy(3).addTo(map)

            // set_postion(parseFloat(buildings_object.buildings[0].coordinate.longitude), parseFloat(buildings_object.buildings[0].coordinate.latitude), 234);
            set_postion(55.28796135101064, 25.22355120343103, 425);

            pointx = {
                "type": "FeatureCollection",
                "features": [{
                    "type": "Feature",
                    "geometry": {
                        "type": "Point",
                        "coordinates": [BlueDot_location.lng, BlueDot_location.lat]
                    },
                    "properties": {
                        "heading": 0
                    }
                }]
            }

            map.addSource('pointx', {
                "type": "geojson",
                "data": pointx
            }),


                map.addLayer({
                    "id": "pointx",
                    "source": "pointx",
                    "type": "symbol",
                    "paint": {
                        "icon-color": "rgb(255, 255, 255)",
                    },
                    "layout": {
                        // "icon-image": "direction-15",
                        //"icon-image": "triangle-15",
                        "icon-rotate": {
                            "type": "identity",
                            "property": "heading"
                        },
                        "icon-anchor": "bottom",
                        "icon-offset": [0, 0],
                        "icon-allow-overlap": true
                    },
                    // "minzoom":20
                });
            Im_here_marker.className = 'marker';
            Im_here_marker.textContent = "You Are Here";

            here_marker = new mapboxgl.Marker({
                element: Im_here_marker,
                anchor: 'bottom' // Use 'bottom' anchor to position the marker above the coordinates
            })
                .setLngLat([blueDot.getLngLat().lng, blueDot.getLngLat().lat])
                .addTo(map);
            //SetCurrentLocation();
        }

        var here_marker;
        const Im_here_marker = document.createElement('div');

        // 8 - Function Floor layers API
        async function Load_Layer_data() {
            Layers_objects = new Array();
            for (var c = 0; c < buildings_object.buildings.length; c++) {
                for (var z = 0; z < floors_objects[c].building_floors.length; z++) {
                    var floor_title = floors_objects[c].building_floors[z].name;
                    var build_id = buildings_object.buildings[c].id;
                    var xhr = new XMLHttpRequest();
                    xhr.addEventListener("readystatechange", function () {
                        if (this.readyState == 4) {
                            Layers_objects.push(JSON.parse(this.responseText));
                        }
                    });
                    xhr.open("GET", API_URL + "floors/" + floors_objects[c].building_floors[z].id, false);
                    xhr.setRequestHeader("Authorization", "Bearer " + Bearer_token);
                    xhr.setRequestHeader("accept", "application/json");
                    xhr.setRequestHeader("Content-Encoding", "gzip,deflate, br");
                    xhr.send();
                }
            }
        }

        // 9 - Function add layers to map
        async function layers_level(sortedInput) {

            if (sortedInput[0].building_floor.layers.length > 0) {

                for (var c = 0; c < sortedInput.length; c++) {

                    var floor_title = sortedInput[c].building_floor.name;

                    if (floor_title == "G") {
                        floor_title = 0;
                    } else {
                        floor_title = parseInt(floor_title);
                    }

                    var build_id = sortedInput[c].building_floor.building_id;
                    var floor_id = sortedInput[c].building_floor.id;
                    level_array[floor_id] = floor_title;



                    for (var m = 0; m < sortedInput[c].building_floor.layers.length; m++) {

                        var kind = sortedInput[c].building_floor.layers[m].kind;
                        var url = sortedInput[c].building_floor.layers[m].file.url;

                        if (!Layersnames.includes(kind)) {
                            if (kind == "other") {
                                Layersnames.push(sortedInput[c].building_floor.layers[m].file.filename);

                            } else {
                                Layersnames.push(kind);
                            }
                        }

                        var sor = map.getLayer(build_id + "/" + floor_title + "/" + kind);

                        if (typeof sor == 'undefined') {



                            if (kind == "walls") {
                                walls_layer(build_id + "/" + floor_title + "/" + kind, url);
                                //up_blue_dot(build_id, floor_title, kind);

                            } else if (kind == "street") {
                                street_layer(build_id + "/" + floor_title + "/" + kind, url);
                                //up_blue_dot(build_id, floor_title, kind);

                            } else if (kind == "rooms") {
                                //rooms_layer(build_id + "/" + floor_title + "/" + kind, url);
                                //up_blue_dot(build_id, floor_title, kind);

                            } else if (kind == "sidewalk") {
                                sidewalk_layer(build_id + "/" + floor_title + "/" + kind, url);
                                //up_blue_dot(build_id, floor_title, kind);

                            } else if (kind == "parking") {
                                parking_layer(build_id + "/" + floor_title + "/" + kind, url);
                                //up_blue_dot(build_id, floor_title, kind);

                            } else if (kind == "outlayer") {
                                outlayer_layer(build_id + "/" + floor_title + "/" + kind, url);
                                //up_blue_dot(build_id, floor_title, kind);
                            } else if (kind == "doors") {
                                doors_layer(build_id + "/" + floor_title + "/" + kind, url);
                                //up_blue_dot(build_id, floor_title, kind);

                            } else if (kind == "corridors") {
                                corridors_layer(build_id + "/" + floor_title + "/" + kind, url);
                                //up_blue_dot(build_id, floor_title, kind);

                            } else if (kind == "arrows") {
                                arrows_layer(build_id + "/" + floor_title + "/" + kind, url);
                                //up_blue_dot(build_id, floor_title, kind);

                            } else if (kind == "garden") {
                                garden_layer(build_id + "/" + floor_title + "/" + kind, url);
                                //up_blue_dot(build_id, floor_title, kind);

                            } else if (kind == "be") {
                                be_layer(build_id + "/" + floor_title + "/" + kind, url);
                                //up_blue_dot(build_id, floor_title, kind);
                            }
                            else if (kind == "other") {
                                otherlayer(build_id + "/" + floor_title + "/" + sortedInput[c].building_floor.layers[m].file.filename, url);
                                //up_blue_dot(build_id, floor_title, sortedInput[c].building_floor.layers[m].file.filename);
                            }
                        }
                    }

                    // if (!toggleableLayerIds.includes(floor_title)) {
                    toggleableLayerIds.push(build_id + "/" + floor_title);

                    if (!floornametitle.includes(floor_title)) {
                        if (floor_title == 0) {
                            //toggleableLayerIds.push(build_id + "/" + floor_title);
                            toggleLayer([build_id + "/" + floor_title], "G");
                            floornametitle.push(floor_title);

                        } else {
                            //toggleableLayerIds.push(build_id + "/" + floor_title);
                            toggleLayer([build_id + "/" + floor_title], floor_title);
                            floornametitle.push(floor_title);
                        }
                    }

                    // }
                }
            } else {

                flag_layer = false;
                if (!Layersnames.includes("img")) {
                    Layersnames.push("img");
                }
                for (var c = 0; c < sortedInput.length; c++) {

                    var floor_title = sortedInput[c].building_floor.name;

                    if (floor_title == "G") {
                        floor_title = 0;
                    } else {
                        floor_title = parseInt(floor_title);
                    }
                    var build_id = sortedInput[c].building_floor.building_id;
                    var floor_id = sortedInput[c].building_floor.id;
                    var url = sortedInput[c].building_floor.photo.url;
                    level_array[floor_id] = floor_title;

                    var POI_coordinates_2 = new Array();

                    for (var j = 0; j < sortedInput[c].building_floor.coordinates.length; j++) {
                        POI_coordinates_2.push([parseFloat(sortedInput[c].building_floor.coordinates[j].longitude), parseFloat(sortedInput[c].building_floor.coordinates[j].latitude)]);
                    }

                    map.addSource(build_id + "/" + floor_title + "/img", {
                        "type": "image",
                        "url": url,
                        "coordinates": POI_coordinates_2
                    });

                    map.addLayer({
                        "id": build_id + "/" + floor_title + "/img",
                        "source": build_id + "/" + floor_title + "/img",
                        "type": "raster",
                        "paint": {
                            "raster-opacity": 0.9,
                            "raster-hue-rotate": 100
                        }

                    });

                    if (!toggleableLayerIds.includes(floor_title)) {
                        if (floor_title == 0) {
                            toggleableLayerIds.push(build_id + "/" + floor_title);
                            toggleLayer([build_id + "/" + floor_title], "G");
                        } else {
                            toggleableLayerIds.push(build_id + "/" + floor_title);
                            toggleLayer([build_id + "/" + floor_title], floor_title);
                        }
                    }
                }
            }
        }

        // 10 - Function to load POIs for each floor.
        async function load_pois_floors(sortedlayer) {
            var layer_length = sortedlayer.length;
            for (var i = 0; i < layer_length; i++) {
                // function GET POI API.
                get_All_POI(sortedInput[i].building_floor.id, sortedInput[i].building_floor.name, Bearer_token, sortedInput[i].building_floor.building_id);
            }
        }

        //11 - Function GET POI API
        async function get_All_POI(floor_id, floor_title, token, building_id) {
            var xhr = new XMLHttpRequest();
            xhr.open("GET", API_URL + "buildings/" + building_id + "/floors/" + floor_id + "/pois", true);
            xhr.setRequestHeader("Authorization", "Bearer " + token);
            xhr.setRequestHeader("accept", "application/json");
            xhr.setRequestHeader("Content-Encoding", "gzip");
            xhr.onload = function (e) {
                var POI_object_floor;
                POI_object_floor = JSON.parse(this.responseText)
                pois_arr.push(POI_object_floor);
                start_poi(POI_object_floor);
                counter++;
                if (counter == sortedInput.length) {
                    switch_to_floor();
                    poi_show_by_level();

                    // Switch_floor(0, 'groundfloor');
                    // var menu = document.getElementById("menu");
                    // for (var i = 0; i < menu.childElementCount; i++) {
                    //     if (menu.childNodes[i].innerText == "G") {
                    //         menu.childNodes[i].className = "active"
                    //         noground = true;
                    //     }
                    //     if (i == (menu.childElementCount - 1) && !noground) {
                    //         menu.childNodes[menu.childElementCount - 1].className = "active";
                    //         menu.children[menu.childElementCount - 1].click();
                    //         current_lvl = parseFloat(menu.children[0].innerText);
                    //     }
                    // }

                    // setTimeout(() => {
                    //     var menu = document.getElementById("menu");
                    //     for (var i = 0; i < menu.childElementCount; i++) {
                    //         if (menu.childNodes[i].innerText == "G") {
                    //             menu.childNodes[i].className = "active"
                    //         }
                    //     }
                    //     $(".instructions").show();
                    // }, 1000);
                }
            };
            xhr.onerror = function () {
                console.error("** An error occurred during the XMLHttpRequest");
            };
            xhr.send();
        }
        // POI 
        async function start_poi(POI_object) {
            poi(POI_object);
        }
        // POI 
        function poi(POI_object) {
            for (var r = POI_object.building_pois.length; r >= 0; r--) {
                if (POI_object.building_pois[r] != undefined) {
                    POI_properties(POI_object.building_pois[r]);
                }
            }
        }

        // Function to extract properties from POI json object.
        async function POI_properties(POI_object) {
            var POI_coordinates = new Array();
            var image_url = "";
            var image_name = "";

            if (POI_object.hasOwnProperty("icon")) {
                if (POI_object.icon.url != "" || POI_object.icon.filename != "") {
                    image_url = POI_object.icon.url;
                    //console.log(image_url);
                    image_name = POI_object.icon.filename;
                    get_image(image_url, image_name);
                }
            }

            var poi_sized = POI_object.coordinates.length;
            for (var j = 0; j < poi_sized; j++) {
                POI_coordinates.push([POI_object.coordinates[j].longitude, POI_object.coordinates[j].latitude])
            }

            var tit_;
            var sub_;

            tit_ = POI_object.title;
            var color = POI_object.color

            if (!isNaN(tit_)) {
                tit_ = "";
                color = "#CDD0CB"
            }

            sub_ = POI_object.subtitles;
            All_POI_object.features[POI_counter] = {
                "id": POI_object.id,
                'type': 'Feature',
                "properties": {
                    "title": tit_,
                    "icon": image_name,
                    "icon_url": image_url,
                    "category_id": POI_object.category_id,
                    "subtitles": sub_,
                    "Center": [POI_object.longitude, POI_object.latitude],
                    "Level": level_array[POI_object.building_floor_id],
                    "Color": color
                },
                "geometry": {
                    "coordinates": [POI_coordinates],
                    "type": "Polygon"
                }
            }

            Level_route_poi = parseInt(level_title);
            //poi_show_by_level();
            //map.moveLayer('polygons', 'mm-bluedot-accuracy1');
            //map.moveLayer('pointx', 'mm-bluedot-accuracy1');
            POI_counter++;
            load_pois_dropdownlist(POI_object);
        }

        function lang_change(l) {
            language = l;
        }

        // 12 - function to load POI icons.
        async function get_image(url, name) {
            var image_url = url;
            var image_name = name;
            // if(image_name.includes("Hall"))
            // {
            //     console.log(image_name);
            //     console.log(image_url)

            // }
            map.loadImage(image_url, function (error, image) {
                if (error) throw error;
                if (!(map.listImages().includes(image_name))) {
                    map.addImage(image_name, image);
                }
            });
        }

        var Fs;
        // 13 - function to view POI in map
        function poi_show_by_level() {
            var counter = 0;
            var counter_building = 0;
            var counter_fs = 0;

            Poly_geojson_level = {
                'type': 'FeatureCollection',
                'features': [{
                    'id': "",
                    'type': 'Feature',
                    'geometry': {
                        'type': "Polygon",
                        'coordinates': []
                    },
                    'properties': {
                        'title': '',
                        'icon': "",
                        "Center": []
                    }
                }]
            };

            Fs = {
                'type': 'FeatureCollection',
                'features': [{
                    'id': "",
                    'type': 'Feature',
                    'geometry': {
                        'type': "Polygon",
                        'coordinates': []
                    },
                    'properties': {
                        'title': '',
                        'icon': "",
                        "Center": []
                    }
                }]
            };

            Poly_geojson_level_outsidebuilding = {
                'type': 'FeatureCollection',
                'features': [{
                    'id': "",
                    'type': 'Feature',
                    'geometry': {
                        'type': "Polygon",
                        'coordinates': []
                    },
                    'properties': {
                        'title': '',
                        'icon': "",
                        "Center": []
                    }
                }]
            };

            if (language == "AR") {
                for (var i = 0; i < All_POI_object.features.length; i++) {

                    if (All_POI_object.features[i].properties.hasOwnProperty("icon") && imageload_flag) {
                        if (All_POI_object.features[i].properties.icon_url != "" && All_POI_object.features[i].properties.icon_url != undefined) {
                            image_url = All_POI_object.features[i].properties.icon_url;
                            image_name = All_POI_object.features[i].properties.icon;
                            get_image(image_url, image_name);
                        }
                    }

                    if (Level_route_poi == All_POI_object.features[i].properties.Level) {

                        if (All_POI_object.features[i].properties.title == "room") {
                            All_POI_object.features[i].properties.title = "";
                        }

                        // if(All_POI_object.features[i].properties.Color == "#ffffff")
                        // {
                        //     All_POI_object.features[i].properties.Color = "#f2f2f2"
                        // }
                        var color = All_POI_object.features[i].properties.Color;

                        // if(All_POI_object.features[i].properties.title.includes("Reception"))
                        // {
                        //     color = "#ff0000";
                        // }


                        Poly_geojson_level.features[counter] =
                        {
                            "id": All_POI_object.features[i].id,
                            'type': 'Feature',
                            "properties": {
                                "title": All_POI_object.features[i].properties.title,
                                "icon": All_POI_object.features[i].properties.icon,
                                "icon_url": All_POI_object.features[i].properties.icon_url,
                                "Center": All_POI_object.features[i].properties.Center,
                                "Level": All_POI_object.features[i].properties.Level,
                                "Color": color
                            },
                            "geometry": {
                                "coordinates": All_POI_object.features[i].geometry.coordinates,
                                "type": "Polygon"
                            }
                        }
                        counter++;

                        if (All_POI_object.features[i].properties.title == "Admin Building Entrance" || All_POI_object.features[i].properties.title == "Burjeel Darak Entrance") {
                            Poly_geojson_level_outsidebuilding.features[counter_building] = {
                                "id": All_POI_object.features[i].id,
                                'type': 'Feature',
                                "properties": {
                                    "title": All_POI_object.features[i].properties.title,
                                    "icon": All_POI_object.features[i].properties.icon,
                                    "icon_url": All_POI_object.features[i].properties.icon_url,
                                    "Center": All_POI_object.features[i].properties.Center,
                                    "Level": All_POI_object.features[i].properties.Level,
                                    "Color": All_POI_object.features[i].properties.Color
                                },
                                "geometry": {
                                    "coordinates": All_POI_object.features[i].geometry.coordinates,
                                    "type": "Polygon"
                                }
                            }
                            counter_building++;
                        }


                        // if (All_POI_object.features[i].properties.title == "F1" || All_POI_object.features[i].properties.title == "F2" || All_POI_object.features[i].properties.title == "F3"||All_POI_object.features[i].properties.title == "F4") {
                        //     Fs.features[counter_fs] = {
                        //     "id": All_POI_object.features[i].id,
                        //     'type': 'Feature',
                        //     "properties": {
                        //         "title": All_POI_object.features[i].properties.title,
                        //         "icon": All_POI_object.features[i].properties.icon,
                        //         "icon_url": All_POI_object.features[i].properties.icon_url,
                        //         "Center": All_POI_object.features[i].properties.Center,
                        //         "Level": All_POI_object.features[i].properties.Level,
                        //         "Color": All_POI_object.features[i].properties.Color
                        //     },
                        //     "geometry": {
                        //         "coordinates": All_POI_object.features[i].geometry.coordinates,
                        //         "type": "Polygon"
                        //     }
                        // }
                        // counter_fs++;
                        // }


                    }
                }
                imageload_flag = false;
            } else {

                for (var i = 0; i < All_POI_object.features.length; i++) {

                    if (All_POI_object.features[0].properties.hasOwnProperty("icon") && imageload_flag) {
                        get_image(All_POI_object.features[i].properties.icon_url, All_POI_object.features[i].properties.icon);
                    }
                    if (Level_route_poi == All_POI_object.features[i].properties.Level) {
                        var title;
                        if (All_POI_object.features[i].properties.subtitles.length > 0) {
                            if (All_POI_object.features[i].properties.subtitles[0] != "string") {
                                title = All_POI_object.features[i].properties.subtitles[0];
                            } else {
                                title = All_POI_object.features[i].properties.title;
                            }
                        } else {
                            title = All_POI_object.features[i].properties.title;
                        }


                        if (title == "Admin Building Entrance" || title == "Burjeel Darak Entrance") {
                            Poly_geojson_level_outsidebuilding.features[counter_building] = {
                                "id": All_POI_object.features[i].id,
                                'type': 'Feature',
                                "properties": {
                                    "title": title,
                                    "icon": All_POI_object.features[i].properties.icon,
                                    "icon_url": All_POI_object.features[i].properties.icon_url,
                                    "Center": All_POI_object.features[i].properties.Center,
                                    "Level": All_POI_object.features[i].properties.Level,
                                    "Color": All_POI_object.features[i].properties.Color
                                },
                                "geometry": {
                                    "coordinates": All_POI_object.features[i].geometry.coordinates,
                                    "type": "Polygon"
                                }
                            }
                            counter_building++;
                        }


                        // if (title == "F1" || title == "F2" || title == "F3" || title == "F4") {
                        //     Fs.features[counter_fs] = {
                        //     "id": All_POI_object.features[i].id,
                        //     'type': 'Feature',
                        //     "properties": {
                        //         "title": title,
                        //         "icon": All_POI_object.features[i].properties.icon,
                        //         "icon_url": All_POI_object.features[i].properties.icon_url,
                        //         "Center": All_POI_object.features[i].properties.Center,
                        //         "Level": All_POI_object.features[i].properties.Level,
                        //         "Color": All_POI_object.features[i].properties.Color
                        //     },
                        //     "geometry": {
                        //         "coordinates": All_POI_object.features[i].geometry.coordinates,
                        //         "type": "Polygon"
                        //     }
                        // }
                        // counter_fs++;
                        //}


                        Poly_geojson_level.features[counter] = {
                            "id": All_POI_object.features[i].id,
                            'type': 'Feature',
                            "properties": {
                                "title": title,
                                "icon": All_POI_object.features[i].properties.icon,
                                "icon_url": All_POI_object.features[i].properties.icon_url,
                                "Center": All_POI_object.features[i].properties.Center,
                                "Level": All_POI_object.features[i].properties.Level,
                                "Color": All_POI_object.features[i].properties.Color
                            },
                            "geometry": {
                                "coordinates": All_POI_object.features[i].geometry.coordinates,
                                "type": "Polygon"
                            }
                        }
                        counter++;
                    }
                }
                imageload_flag = false;
            }

            var mapLayer = map.getLayer('polygons');
            var mapSource = map.getSource('municipalities');

            var maplayer_outside = map.getLayer('maplayersoutside');
            var mapsource_outside = map.getSource('maplayersoutside');
            if (typeof mapsource_outside !== 'undefined') {
                map.removeLayer("maplayersoutside");
                map.removeSource("maplayersoutside");
            }
            // 
            if (typeof mapSource !== 'undefined') {
                map.removeLayer("polygons");
                map.removeLayer("polygons_outline");
                map.removeLayer("municipality-name");
                map.removeSource("municipalities");
            }

            if (Poly_geojson_level_outsidebuilding.features.length >= 2) {

                map.addSource("maplayersoutside", {
                    type: "geojson",
                    data: Poly_geojson_level_outsidebuilding,
                });


                map.addLayer({
                    'id': "maplayersoutside",
                    'type': 'fill-extrusion',
                    'source': "maplayersoutside",
                    'paint': {
                        'fill-extrusion-color': '#E6DDC4',
                        'fill-extrusion-height': 15,
                        'fill-extrusion-opacity': 0.85

                    }
                });

            }


            map.addSource("municipalities", {
                type: "geojson",
                data: All_POI_object,
            });



            map.addLayer({
                id: "polygons",
                type: "fill-extrusion",
                source: "municipalities",
                'layout': {
                    'fill-extrusion-edge-radius': 0.3,
                },
                'paint': {
                    'fill-extrusion-rounded-roof': true,
                    'fill-extrusion-line-width': 1,
                    'fill-extrusion-height': [
                        'case',
                        ['boolean', ['feature-state', 'selected'], false], 3, // Purple for selected
                        2 // Default color for others
                    ],
                    // 'fill-extrusion-color': 
                    // {
                    //     "type": "identity",
                    //     "property": "Color"
                    // }
                    'fill-extrusion-color': [
                        'case',
                        ['boolean', ['feature-state', 'selected'], false], '#FFA500', // Purple for selected
                        ['get', 'Color']  // Default color for others
                    ]
                    ,
                    'fill-extrusion-opacity': [
                        'interpolate',
                        // Set the exponential rate of change to 0.5
                        ['exponential', 0.1],
                        ['zoom'],
                        // When zoom is 10, buildings will be 100% transparent.
                        17,
                        0.7,
                        // When zoom is 18 or higher, buildings will be 100% opaque.
                        20.31967926651499,
                        1,
                    ]
                    // 'fill-outline-color': "#a1a6a2"

                }
            });


            map.addLayer({
                id: "polygons_outline",
                type: "line",
                source: "municipalities",
                'layout': { 'visibility': 'none' },
                'paint': {
                    'line-color': '#828282',
                    'line-width': [
                        'interpolate',
                        // Set the exponential rate of change to 0.5
                        ['exponential', 0.1],
                        ['zoom'],
                        // When zoom is 10, buildings will be 100% transparent.
                        17,
                        0,
                        // When zoom is 18 or higher, buildings will be 100% opaque.
                        22,
                        1,
                    ],
                    'line-opacity': [
                        'interpolate',
                        // Set the exponential rate of change to 0.5
                        ['exponential', 0.1],
                        ['zoom'],
                        // When zoom is 10, buildings will be 100% transparent.
                        17,
                        0,
                        // When zoom is 18 or higher, buildings will be 100% opaque.
                        20.31967926651499,
                        0.6,
                    ]
                }
            });

            map.addLayer({
                id: "municipality-name",
                type: "symbol",
                source: "municipalities",
                layout: {
                    "icon-anchor": "bottom",
                    "icon-allow-overlap": true,
                    "icon-image": "{icon}",
                    'icon-size': 0.08,
                    "text-field": "{title}",
                    "text-size": 20,
                    //'text-font': ["Arial Unicode MS Regular"],
                    'text-offset': [0, 0.8],
                    'symbol-placement': "point"
                },
                paint: {
                    'icon-opacity': [
                        'interpolate',
                        // Set the exponential rate of change to 0.5
                        ['exponential', 0.1],
                        ['zoom'],
                        // When zoom is 10, buildings will be 100% transparent.
                        17,
                        0,
                        // When zoom is 18 or higher, buildings will be 100% opaque.
                        20.31967926651499,
                        1,
                    ],

                    'text-opacity': [
                        'interpolate',
                        // Set the exponential rate of change to 0.5
                        ['exponential', 0.1],
                        ['zoom'],
                        // When zoom is 10, buildings will be 100% transparent.
                        17,
                        0,
                        // When zoom is 18 or higher, buildings will be 100% opaque.
                        20.31967926651499,
                        0.8,
                    ],
                    "text-color": ["case",
                        ["boolean", ["feature-state", "hover"], false],
                        'rgba(0,0,0,1)',
                        'rgba(0,0,0,1)'
                    ],
                    "text-halo-color": ["case",
                        ["boolean", ["feature-state", "hover"], false],
                        'rgba(255,255,255,1)',
                        'rgba(255,255,255,1)'
                    ],
                    "text-halo-width": 2,
                    "text-halo-blur": 0,
                }
            });
            map.moveLayer('polygons', 'mm-bluedot-accuracy1');
            map.moveLayer('polygons', 'pointx');
            map.moveLayer('polygons_outline', 'mm-bluedot-accuracy1');

        }

        function getEdgeLines(polygonCoordinates) {
            return polygonCoordinates.map((coordinate, index) => {
                // Generate the LineString for the polygon's edges
                const nextIndex = (index + 1) % polygonCoordinates.length; // Wrap around to close the polygon
                return [coordinate, polygonCoordinates[nextIndex]];
            });
        }

        // function add Walls Layers
        function walls_layer(layername, path) {
            map.addSource(layername, {
                type: 'geojson',
                data: path
            });
            map.addLayer({
                'id': layername,
                'type': 'fill',
                'source': layername,
                'paint': {
                    'fill-color': '#E6E9EC',

                    'fill-opacity': [
                        'interpolate',
                        // Set the exponential rate of change to 0.5
                        ['exponential', 0.1],
                        ['zoom'],
                        // When zoom is 10, buildings will be 100% transparent.
                        17,
                        0,
                        // When zoom is 18 or higher, buildings will be 100% opaque.
                        20.31967926651499,
                        1,
                    ]
                }
            });
            map.setLayoutProperty(layername, 'visibility', 'none');
        }

        // function add street Layers
        function street_layer(layername, path) {
            map.addSource(layername, {
                type: 'geojson',
                data: path
            });
            map.addLayer({
                'id': layername,
                'type': 'fill',
                'source': layername,
                'paint': {
                    'fill-color': '#bababa'
                }
            });
            map.setLayoutProperty(layername, 'visibility', 'none');
        }

        // function add rooms Layers
        function rooms_layer(layername, path) {
            map.addSource(layername, {
                type: 'geojson',
                data: path
            });
            map.addLayer({
                'id': layername,
                'type': 'fill-extrusion',
                'source': layername,
                'paint': {
                    'fill-extrusion-color': '#F1ECE1',
                    'fill-extrusion-height': 2,
                    'fill-extrusion-opacity': [
                        'interpolate',
                        // Set the exponential rate of change to 0.5
                        ['exponential', 0.1],
                        ['zoom'],
                        // When zoom is 10, buildings will be 100% transparent.
                        17,
                        0,
                        // When zoom is 18 or higher, buildings will be 100% opaque.
                        20.31967926651499,
                        1,
                    ]
                }
            });
            map.setLayoutProperty(layername, 'visibility', 'none');
        }

        // function add side walk Layers
        function sidewalk_layer(layername, path) {

            map.addSource(layername, {
                type: 'geojson',
                data: path
            });


            map.addLayer({
                'id': layername,
                'type': 'fill',
                'source': layername,
                'paint': {
                    'fill-color': '#F4F1EC',
                    'fill-outline-color': '#ededed',
                    'fill-pattern': "sidewalk3.jpg",
                    'fill-opacity': 0.5

                }
            });


            // map.addLayer({
            //     'id': layername,
            //     'type': 'fill-extrusion',
            //     'source': layername,
            //     'paint': {
            //         'fill-extrusion-color': '#E6E4E0',
            //         'fill-extrusion-height' : 0.3,
            //         'fill-extrusion-opacity': [
            //          'interpolate',
            //        // Set the exponential rate of change to 0.5
            //         ['exponential', 0.1],
            //         ['zoom'],
            //         // When zoom is 10, buildings will be 100% transparent.
            //         16,
            //         0,
            //         // When zoom is 18 or higher, buildings will be 100% opaque.
            //         20.31967926651499,
            //         1,
            //         ]
            //     }
            // });


            map.setLayoutProperty(layername, 'visibility', 'none');
        }

        // function add parking Layers
        function parking_layer(layername, path) {
            map.addSource(layername, {
                type: 'geojson',
                data: path
            });
            map.addLayer({
                'id': layername,
                'type': 'fill',
                'source': layername,
                'paint': {
                    'fill-color': '#FFEBAF',
                    'fill-opacity': [
                        'interpolate',
                        // Set the exponential rate of change to 0.5
                        ['exponential', 0.1],
                        ['zoom'],
                        // When zoom is 10, buildings will be 100% transparent.
                        17,
                        0,
                        // When zoom is 18 or higher, buildings will be 100% opaque.
                        20.31967926651499,
                        1,
                    ],
                    'fill-outline-color': '#FFEBAF'
                }
            });
            map.setLayoutProperty(layername, 'visibility', 'none');
        }
        var lc = 0;
        // function add outlayer Layers
        function outlayer_layer(layername, path) {

            map.addSource(layername, {
                type: 'geojson',
                data: path
            });

            map.addLayer({
                'id': layername,
                'type': 'line',
                'source': layername,
                'layout': {},
                'paint': {
                    'line-color': '#141414',
                    'line-width': [
                        'interpolate',
                        // Set the exponential rate of change to 0.5
                        ['exponential', 0.1],
                        ['zoom'],
                        // When zoom is 10, buildings will be 100% transparent.
                        17,
                        0,
                        // When zoom is 18 or higher, buildings will be 100% opaque.
                        22,
                        3,
                    ]

                }
            });


            map.setLayoutProperty(layername, 'visibility', 'none');
        }

        // function add other layer Layers
        function otherlayer(layername, path) {
            map.addSource(layername, {
                type: 'geojson',
                data: path,
                'lineMetrics': true
            });
            map.addLayer({
                'id': layername,
                'type': 'line',
                'source': layername,
                'layout': {
                    'line-cap': 'round',   // Smooth ends of the line
                    'line-join': 'round'  // Smooth joins between segments
                },
                'paint': {
                    'line-gradient': [
                        'interpolate',
                        ['linear'],
                        ['line-progress'],  // Gradient progresses along the line
                        0, 'blue',          // Start color
                        0.5, 'purple',      // Middle color
                        1, 'red'            // End color
                    ],
                    // Dash pattern: alternating dash and gap lengths
                    'line-dasharray': [1, 1],
                    'line-width': 1,
                    'line-opacity': [
                        'interpolate',
                        // Set the exponential rate of change to 0.5
                        ['exponential', 0.1],
                        ['zoom'],
                        // When zoom is 10, buildings will be 100% transparent.
                        17,
                        0,
                        // When zoom is 18 or higher, buildings will be 100% opaque.
                        20.31967926651499,
                        1,
                    ]
                }
            });
            map.setLayoutProperty(layername, 'visibility', 'none');
        }

        function arrows_layer(layername, path) {
            map.addSource(layername, {
                type: 'geojson',
                data: path
            });
            map.addLayer({
                'id': layername,
                'type': 'fill',
                'source': layername,
                'layout': {},
                'paint': {
                    'fill-color': '#ffffff',
                    'fill-outline-color': '#ffffff',
                    'fill-opacity': [
                        'interpolate',
                        // Set the exponential rate of change to 0.5
                        ['exponential', 0.1],
                        ['zoom'],
                        // When zoom is 10, buildings will be 100% transparent.
                        17,
                        0,
                        // When zoom is 18 or higher, buildings will be 100% opaque.
                        20.31967926651499,
                        1,
                    ]
                }
            });
            map.setLayoutProperty(layername, 'visibility', 'none');
        }

        // function otherlayer(layername, path) {

        //     map.addSource(layername, {
        //         type: 'geojson',
        //         data: path
        //     });

        //     map.addLayer({
        //         'id': layername,
        //         'type': 'line',
        //         'source': layername,
        //         'layout': {},
        //         'paint': {
        //             'line-color': '#8c8c8c',
        //             'line-width': 1
        //         }
        //     });
        //     map.setLayoutProperty(layername, 'visibility', 'none');
        // }

        // function add doors layer Layers
        function doors_layer(layername, path) {

            map.addSource(layername, {
                type: 'geojson',
                data: path
            });

            map.addLayer({
                'id': layername,
                'type': 'fill',
                'source': layername,
                'paint': {
                    'fill-color': '#F2DCBB',
                    'fill-outline-color': '#000000',
                    'fill-opacity': [
                        'interpolate',
                        // Set the exponential rate of change to 0.5
                        ['exponential', 0.1],
                        ['zoom'],
                        17,
                        0,
                        20.31967926651499,
                        1,
                    ]
                }
            });

            map.setLayoutProperty(layername, 'visibility', 'none');
        }

        // function add Cooridors layer Layers
        function corridors_layer(layername, path) {
            map.addSource(layername, {
                type: 'geojson',
                data: path
            });
            map.addLayer({
                'id': layername,
                'type': 'fill',
                'source': layername,
                'paint': {
                    'fill-color': '#ffffff',
                    //'fill-outline-color': '#828282',
                    'fill-opacity': [
                        'interpolate',
                        // Set the exponential rate of change to 0.5
                        ['exponential', 0.1],
                        ['zoom'],
                        // When zoom is 10, buildings will be 100% transparent.
                        17,
                        0,
                        // When zoom is 18 or higher, buildings will be 100% opaque.
                        20.31967926651499,
                        1,
                    ]
                }
            });
            map.setLayoutProperty(layername, 'visibility', 'none');
        }

        // function add belcony layer Layers
        function be_layer(layername, path) {
            map.addSource(layername, {
                type: 'geojson',
                data: path
            });

            map.addLayer({
                'id': layername,
                'type': 'fill',
                'source': layername,
                'paint': {
                    'fill-color': [
                        'match',
                        ['get', 'Entrance_type'],
                        'ENTER', '#629584', // Green for 'ENTER'
                        'EXIT', '#BC7C7C',  // Red for 'EXIT'
                        '#000000'           // Default color (black) if no match
                    ],
                    'fill-outline-color': [
                        'match',
                        ['get', 'Entrance_type'],
                        'ENTER', '#629584', // Green for 'ENTER'
                        'EXIT', '#BC7C7C',  // Red for 'EXIT'
                        '#000000'           // Default color (black) if no match
                    ],
                    'fill-opacity': [
                        'interpolate',
                        // Set the exponential rate of change to 0.5
                        ['exponential', 0.1],
                        ['zoom'],
                        // When zoom is 10, buildings will be 100% transparent.
                        17,
                        0,
                        // When zoom is 18 or higher, buildings will be 100% opaque.
                        20.31967926651499,
                        1,
                    ]
                }
            });
            map.setLayoutProperty(layername, 'visibility', 'none');

        }



        // function add garden layer Layers
        function garden_layer(layername, path) {
            map.addSource(layername, {
                type: 'geojson',
                data: path
            });

            map.addLayer({
                'id': layername,
                'type': 'fill',
                'source': layername,
                'paint': {
                    'fill-color': '#3D8361',
                    //'fill-pattern': "grass.jpg",
                    'fill-opacity': 0.7
                }
            });
            map.setLayoutProperty(layername, 'visibility', 'none');
        }

        //14 - Function to get Route
        async function route() {
            // fetch Route
            await load_routes();
            start_routes();
        }

        // 15 - function to fetch route by level
        function load_routes() {

            for (var z = 0; z < floors_objects.length; z++) {
                // Fetch route by level
                for (var f = 0; f < floors_objects[z].building_floors.length; f++) {
                    get_routes(Bearer_token, floors_objects[z].building_floors[f].id);
                }
            }
        }

        // 16 - Function GET Routes API
        async function get_routes(token, building_id) {
            var xhr = new XMLHttpRequest();
            xhr.addEventListener("readystatechange", function () {
                if (this.readyState == 4) {
                    var points_route_object = new Array();
                    points_route_object.push(JSON.parse(this.responseText));
                    // points_route_object = points_route_object.filter(function () {
                    //     return true
                    // });
                    Route_buildings[building_id] = points_route_object;
                }
            });
            xhr.open("GET", API_URL + "floors/" + building_id + "/route", false);
            xhr.setRequestHeader("Authorization", "Bearer " + token);
            xhr.setRequestHeader("accept", "application/json");
            xhr.setRequestHeader("Content-Encoding", "gzip,deflate, br");

            xhr.send();
        }

        // Proccess Route to fit with.
        async function start_routes() {
            for (var key in Route_buildings) {
                wayPoint_level = level_array[key];
                for (var i = 0; i < Route_buildings[key][0].building_route_points.length; i++) {
                    var wayPoint_level;
                    Routes_array[Route_buildings[key][0].building_route_points[i].point_id] = Route_buildings[key][0].building_route_points[i].longitude + "," +
                        Route_buildings[key][0].building_route_points[i].latitude + "," +
                        wayPoint_level + "," +
                        Route_buildings[key][0].building_route_points[i].kind;
                    if (Route_buildings[key][0].building_route_points[i].kind == "elevator") {

                        elevators.push({
                            key: Route_buildings[key][0].building_route_points[i].point_id,
                            lng: Route_buildings[key][0].building_route_points[i].longitude,
                            lat: Route_buildings[key][0].building_route_points[i].latitude,
                            zlevel: wayPoint_level
                        });
                        // const marker1 = new mapboxgl.Marker()
                        // .setLngLat([Route_buildings[key][0].building_route_points[i].longitude,  Route_buildings[key][0].building_route_points[i].latitude])
                        // .addTo(map);
                    }
                    var keys = Route_buildings[key][0].building_route_points[i].neighbors;
                    for (var z = 0; z < keys.length; z++) {
                        graph.addEdge(Route_buildings[key][0].building_route_points[i].point_id, keys[z]);
                        graph.addEdge(keys[z], Route_buildings[key][0].building_route_points[i].point_id);
                    }
                }
            }
            link_elevators()

        }

        function link_elevators() {
            for (var i = 0; i < elevators.length; i++) {
                for (var j = 0; j < elevators.length; j++) {
                    var distance = getDistanceFromLatLonInKm(parseFloat(elevators[i].lat), parseFloat(elevators[i].lng), parseFloat(elevators[j].lat), parseFloat(elevators[j].lng))
                    if (distance < 2) {
                        graph.addEdge(elevators[i].key, elevators[j].key)
                    }
                }
            }
        }

        //Graph
        function Graph() {
            var neighbors = this.neighbors = {}; // Key = vertex, value = array of neighbors.
            this.addEdge = function (u, v) {
                if (neighbors[u] === undefined) { // Add the edge u -> v.
                    neighbors[u] = [];
                }
                neighbors[u].push(v);
                if (neighbors[v] === undefined) { // Also add the edge v -> u in order
                    neighbors[v] = []; // to implement an undirected graph.
                } // For a directed graph, delete
                neighbors[v].push(u); // these four lines.
            };
            return this;
        }


        var gfo;
        function toggleLayer(ids, name) {
            var link = document.createElement('a');
            link.href = '#';
            link.textContent = name;

            var maplayer = map.getLayer(ids[0] + "/" + name);
            if (typeof maplayer !== 'undefined') {
                var active = map.getLayoutProperty(ids[0] + "/" + name, 'visibility');

            }

            if (active == 'visible') {
                link.className = 'active';
                map.on('mouseenter', ids, function (e) {
                    map.getCanvas().style.cursor = 'pointer';
                });
                map.on('mouseleave', ids, function (e) {
                    map.getCanvas().style.cursor = '';
                });
            }

            link.onclick = function (e) {
                if (name == "G") {
                    gfo = 0;
                } else {
                    gfo = name;
                }
                e.preventDefault();
                e.stopPropagation();
                var clickedLayer = this.textContent;
                var trailLayer = toggleableLayerIds.indexOf(clickedLayer);
                var visibility;
                for (layers in ids) {
                    let id = ids[layers]
                    var maplayer = map.getLayer(ids[layers] + "/" + Layersnames[0]);
                    if (typeof maplayer !== 'undefined') {
                        visibility = map.getLayoutProperty(ids[layers] + "/" + Layersnames[0], 'visibility');
                    }
                    if (visibility === 'visible') {
                        //map.setLayoutProperty(ids[layers], 'visibility', 'none');
                        this.className = 'active';
                    } else {
                        this.className = 'active';
                        let getSiblings = function (floor) {
                            // Setup siblings array and get the first sibling
                            let siblings = [];
                            let sibling = floor.parentNode.firstChild;
                            // Loop through each sibling and push to the array
                            while (sibling) {
                                // make sure it is an element and not the required
                                if (sibling.nodeType === 1 && sibling !== floor) {
                                    siblings.push(sibling);
                                }
                                sibling = sibling.nextSibling
                            }
                            return siblings;
                        };
                        let siblings = getSiblings(this);
                        siblings.forEach((x) => {
                            x.className = ""
                        })
                        toggleableLayerIds.map((x) => {
                            var test1 = x.split("/");
                            if (test1[1] == gfo) {
                                for (var name of Layersnames) {
                                    var maplayer = map.getLayer(x + "/" + name);
                                    if (typeof maplayer !== 'undefined') {
                                        map.setLayoutProperty(x + "/" + name, 'visibility', 'visible');
                                        var f = x.split("/");
                                        Level_route_poi = parseInt(f[1]);
                                    }
                                }
                            } else {
                                for (var name of Layersnames) {
                                    var maplayer = map.getLayer(x + "/" + name);
                                    if (typeof maplayer !== 'undefined') {
                                        map.setLayoutProperty(x + "/" + name, 'visibility', 'none');

                                    }
                                }
                            }
                        })

                        var mapLayer = map.getLayer('polygons');
                        var mapSource = map.getSource('municipalities');

                        if (typeof mapSource !== 'undefined') {
                            map.removeLayer("municipality-name");
                            map.removeLayer("polygons");
                            map.removeLayer("polygons_outline");
                            map.removeSource("municipalities");
                        }
                        if (flag_layer) {
                            flag_layer = false;
                        } else {
                            poi_show_by_level();
                            map.moveLayer('polygons', 'mm-bluedot-accuracy1');
                            map.moveLayer('pointx', 'mm-bluedot-accuracy1');
                            map.moveLayer('polygons_outline', 'mm-bluedot-accuracy1');

                        }


                        if (Full_path_route.features[0].geometry.coordinates.length > 0) {
                            var mapLayer = map.getLayer('route');
                            if (!remove_extra_route_flag) {
                                remove_route_layer();
                            }
                            Route_level();
                        }

                        if (Level_route_poi != current_lvl) {

                            map.setPaintProperty("mm-bluedot-circle1", 'circle-color', '#c2c0c0');
                            map.setLayoutProperty("mm-bluedot-accuracy1", 'visibility', 'none');
                            map.setLayoutProperty("pointx", 'visibility', 'none');

                        } else {
                            map.setPaintProperty("mm-bluedot-circle1", 'circle-color', '#3388FF');
                            map.setLayoutProperty("mm-bluedot-accuracy1", 'visibility', 'visible');
                            map.setLayoutProperty("pointx", 'visibility', 'visible');
                        }

                        elevator_guide();



                        if (Level_route_poi != change_lvl) {
                            if (routeEnabled) {
                                map.setLayoutProperty("poi_border", 'visibility', 'none');
                                map.setLayoutProperty("poi_fill", 'visibility', 'none');
                                slct_marker.remove();
                                is_marker_removed = true;

                            }
                        } else {
                            if (routeEnabled) {
                                map.setLayoutProperty("poi_border", 'visibility', 'visible');
                                map.setLayoutProperty("poi_fill", 'visibility', 'visible');
                                if (is_marker_removed) {
                                    is_marker_removed = false;
                                    slct_marker = new mapboxgl.Marker({
                                        color: 'orange'
                                    }).setLngLat([change_lg, change_lt]).addTo(map);
                                    //popup.remove();

                                }

                            }
                        }

                    }

                }

            };

            var layers = document.getElementById('menu');
            layers.appendChild(link);
        }

        // Add poi tilte & subtiltes to dropdownlist : 
        var add_empty_option = true;
        function load_pois_dropdownlist(poi) {

            if(add_empty_option){
                add_empty_option = false;
                $('#TO_Location').append($("<option></option>")); 
            }

            if (!denidlocations_AR.includes(poi.title) && poi.title != "room" && poi.title != "xx") {
                var level = level_array[poi.building_floor_id];
                var category_ar = "GISEC - "+get_terminal_name(parseFloat(poi.longitude) , parseFloat(poi.latitude))+" - ";
                level = arabic_levels[level];
                if (poi.category_id != null) {
                    category_ar = cateogry_array[poi.category_id] + " - "+get_terminal_name(parseFloat(poi.longitude) , parseFloat(poi.latitude))+" - ";
                }
                var icon_url = "";
                if ('icon' in poi) {
                    icon_url = poi.icon.url;
                } else {
                    icon_url = "./images/location.png"
                }
                $('#TO_Location')
                    .append($("<option>")
                        .attr("data-foo", category_ar + " " + level)
                        .attr("data-img", icon_url)
                        .attr("value", poi.longitude + "," + poi.latitude + "," + poi.building_floor_id)
                        .text(poi.title)
                    );
            }

            // if (poi.subtitles.length > 0) {
            //     for(var z = 0 ; z < poi.subtitles.length ; z++){
            //     if (!denidlocations_AR.includes(poi.subtitles[z])) {
            //         var level = level_array[poi.building_floor_id];
            //         var category_ar = "SPL Head Office - ";
            //         level = arabic_levels[level];
            //         if (poi.category_id != null) {
            //             category_ar = cateogry_array[poi.category_id] + " - ";
            //         }
            //         $('#TO_Location')
            //             .append($("<option data-foo='" + category_ar + " " + level + "'>" + poi.subtitles[z] + "</option>")
            //                 .attr("value", poi.longitude + "," + poi.latitude + "," + poi.building_floor_id)
            //             );
            //     }
            // }
            // }

        }

        function get_terminal_name(lng, lat) {
            var buildings_name = ["Hall 8", "Hall 7", "Hall 6", "Hall 5", "Hall 4", "Hall 3", "Hall 1", "Hall 2"];

            var index = -1;
            var current = turf.points([
                [lng, lat]
            ]);
            for (var i = 0; i < Building_names_json.length; i++) {
                var ptsWithin = turf.pointsWithinPolygon(current, Building_names_json[i]);

                if (ptsWithin.features.length > 0) {
                    // Inside  ...
                    index = i;
                    break;
                }
            }
            if (language == "EN") {
                var defaultvalue = "Outside";
            } else {
                var defaultvalue = "خارج"
            }

            if (index != -1) {
                return buildings_name[index]
            } else {
                return defaultvalue;
            }
        }


        var Building_names_json = [
            turf.polygon([
                [
                    [
                        55.288316,
                        25.223225
                    ],
                    [
                        55.287992,
                        25.222787
                    ],
                    [
                        55.288387,
                        25.222548
                    ],
                    [
                        55.288694,
                        25.223002
                    ],
                    [
                        55.288316,
                        25.223225
                    ]
                ]
            ]),

            turf.polygon([
                [
                    [
                        55.287506,
                        25.223702
                    ],
                    [
                        55.287201,
                        25.223244
                    ],
                    [
                        55.287996,
                        25.222787
                    ],
                    [
                        55.288551,
                        25.22357
                    ],
                    [
                        55.287743,
                        25.224041
                    ],
                    [
                        55.287506,
                        25.223702
                    ]
                ]
            ]),
            turf.polygon([
                [
                    [
                        55.286876,
                        25.223438
                    ],
                    [
                        55.287204,
                        25.223247
                    ],
                    [
                        55.287502,
                        25.223707
                    ],
                    [
                        55.28719,
                        25.223886
                    ],
                    [
                        55.286876,
                        25.223438
                    ]
                ]
            ]),

            turf.polygon([
                [
                    [
                        55.287192,
                        25.223887
                    ],
                    [
                        55.286959,
                        25.22402
                    ],
                    [
                        55.286657,
                        25.223565
                    ],
                    [
                        55.286876,
                        25.223437
                    ],
                    [
                        55.287192,
                        25.223887
                    ]
                ]
            ]),

            turf.polygon([
                [
                    [
                        55.287134,
                        25.223921
                    ],
                    [
                        55.2875,
                        25.224425
                    ],
                    [
                        55.287029,
                        25.22469
                    ],
                    [
                        55.286693,
                        25.224174
                    ],
                    [
                        55.287134,
                        25.223921
                    ]
                ]
            ]),

            turf.polygon([
                [
                    [
                        55.287035,
                        25.224691
                    ],
                    [
                        55.287493,
                        25.224426
                    ],
                    [
                        55.287905,
                        25.225024
                    ],
                    [
                        55.28744,
                        25.225273
                    ],
                    [
                        55.287035,
                        25.224691
                    ]
                ]
            ]),

            turf.polygon([
                [
                    [
                        55.288148,
                        25.226333
                    ],
                    [
                        55.287773,
                        25.225777
                    ],
                    [
                        55.288298,
                        25.225501
                    ],
                    [
                        55.288663,
                        25.226033
                    ],
                    [
                        55.288148,
                        25.226333
                    ]
                ]
            ]),

            turf.polygon([
                [
                    [
                        55.28743,
                        25.22527
                    ],
                    [
                        55.287953,
                        25.224994
                    ],
                    [
                        55.288305,
                        25.225502
                    ],
                    [
                        55.287779,
                        25.225785
                    ],
                    [
                        55.28743,
                        25.22527
                    ]
                ]
            ])
        ];

        async function load_english(english) {
            // console.log(english.subtitles.length);
            var englishsize = english.subtitles.length;
            for (var i = 0; i < englishsize; i++) {
                if (!denidlocations_EN.includes(english.subtitles[i].toLowerCase())) {
                    var level = level_array[english.building_floor_id];
                    var category = "SPL Head Office - ";
                    if (level == 0) {
                        level = "G";
                    }
                    if (english.category_id != null) {
                        category = cateogry_array[english.category_id] + " - ";
                    }
                    $('#TO_Location')
                        .append($("<option data-foo='" + category + " الدور : " + level + "'>" + english.subtitles[i] + "</option>")
                            .attr("value", english.longitude + "," + english.latitude + "," + english.building_floor_id)
                        );
                }
            }
            // console.log(english.subtitles.length);
            if (english.subtitles.length > 0) {
                // console.log(english.subtitles[1]);
                for (var z = 0; z < arabic.subtitles.length; z++) {
                    if (!denidlocations_EN.includes(english.subtitles[z])) {
                        var level = level_array[english.building_floor_id];
                        var category_ar = "SPL Head Office - ";
                        level = english[level];
                        if (english.category_id != null) {
                            category_ar = cateogry_array[english.category_id] + " - ";
                        }
                        $('#TO_Location')
                            .append($("<option data-foo='" + category_ar + " " + level + "'>" + english.subtitles[z] + "</option>")
                                .attr("value", english.longitude + "," + english.latitude + "," + english.building_floor_id)
                            );
                    }
                }
            }
        }

        function draw_path(name, lng, lat, zlvl) {
            ClearRoute();
            var poi_name = name;
            var lg = lng;
            var lt = lat;
            var lvl = zlvl;
            var icon_url = "";
            var selected_poi = {
                'type': 'FeatureCollection',
                'features': [{
                    'type': 'Feature',
                    'geometry': {
                        'type': 'LineString',
                        'coordinates': []
                    }
                }]
            };

            change_lg = lg;
            change_lt = lt;
            change_name = poi_name;
            change_lvl = lvl;
            change_icon = icon_url;
            change_selected_poi = selected_poi;

            draw_path_to_poi(poi_name, lg, lt, lvl, icon_url, selected_poi);

        }


        function switch_floor_map(floor_name) {
            var menubtn = document.getElementById("menu");

            for (var i = 0; i < menubtn.childElementCount; i++) {
                var floor = menubtn.children[i].innerText;

                if (floor == floor_name) {
                    menubtn.children[i].click();
                }
            }
        }

        function changelang(lang) {
            // console.log("Language changed to : " + lang);
            if (lang == "AR") {
                language = "AR";

                $('#TO_Location').empty()
                Load_data_drop_language();
            } else {
                language = "EN";

                $('#TO_Location').empty()
                Load_data_drop_language();

            }
            poi_show_by_level();
        }

        // change POI to selected language & dropdownlist. 
        async function Load_data_drop_language() {

            $('#TO_Location').append($("<option data-foo=''></option>"));
            if (language == "EN") {
                var size = All_POI_object.features.length;
                for (var i = 0; i < size; i++) {
                    if (All_POI_object.features[i].properties.subtitles.length > 0) {
                        if (!denidlocations_EN.includes(All_POI_object.features[i].properties.subtitles[0].toLowerCase()) && All_POI_object.features[i].properties.subtitles[0].toLowerCase() != "") {
                            var level = All_POI_object.features[i].properties.Level;
                            var category = "SPL Head Office";
                            if (All_POI_object.features[i].properties.category_id != null) {
                                category = cateogry_array[All_POI_object.features[i].properties.category_id] + " - ";
                            }

                            var array_lev = Object.keys(level_array);
                            var floorid_;

                            for (var a = 0; a < array_lev.length; a++) {
                                if (level_array[array_lev[a]] == level) {
                                    floorid_ = array_lev[a];
                                    level = english_levels[level];
                                }
                            }

                            $('#TO_Location')
                                .append($("<option data-foo='" + category + " " + level + "'>" + All_POI_object.features[i].properties.subtitles[0] + "</option>")
                                    .attr("value", All_POI_object.features[i].properties.Center[0] + "," + All_POI_object.features[i].properties.Center[1] + "," + floorid_)
                                );
                        }

                        if (All_POI_object.features[i].properties.subtitles.length > 1) {
                            if (!denidlocations_EN.includes(All_POI_object.features[i].properties.subtitles[0].toLowerCase()) && All_POI_object.features[i].properties.subtitles[0].toLowerCase() != "") {
                                var level = All_POI_object.features[i].properties.Level;
                                var category = "SPL Head Office";
                                if (All_POI_object.features[i].properties.category_id != null) {
                                    category = cateogry_array[All_POI_object.features[i].properties.category_id] + " - ";
                                }

                                var array_lev = Object.keys(level_array);
                                var floorid_;

                                for (var a = 0; a < array_lev.length; a++) {
                                    if (level_array[array_lev[a]] == level) {
                                        floorid_ = array_lev[a];
                                        level = english_levels[level];
                                    }
                                }

                                $('#TO_Location')
                                    .append($("<option data-foo='" + category + " " + level + "'>" + All_POI_object.features[i].properties.subtitles[1] + "</option>")
                                        .attr("value", All_POI_object.features[i].properties.Center[0] + "," + All_POI_object.features[i].properties.Center[1] + "," + floorid_)
                                    );
                            }

                        }
                    }
                }
            } else {
                var size = All_POI_object.features.length;
                for (var i = 0; i < size; i++) {

                    if (!denidlocations_AR.includes(All_POI_object.features[i].properties.title) && All_POI_object.features[i].properties.title != "") {
                        var level = All_POI_object.features[i].properties.Level;
                        var category_ar = "SPL Head Office";
                        if (All_POI_object.features[i].properties.category_id != null) {
                            category_ar = cateogry_array[All_POI_object.features[i].properties.category_id] + " - ";
                        }
                        var array_lev = Object.keys(level_array);
                        var floorid_;
                        var siz = array_lev.length;

                        for (var a = 0; a < siz; a++) {
                            if (level_array[array_lev[a]] == level) {
                                floorid_ = array_lev[a];
                                level = arabic_levels[level];
                            }
                        }

                        $('#TO_Location')
                            .append($("<option data-foo='" + category_ar + " " + level + "'>" + All_POI_object.features[i].properties.title + "</option>")
                                .attr("value", All_POI_object.features[i].properties.Center[0] + "," + All_POI_object.features[i].properties.Center[1] + "," + floorid_)
                            );

                        if (All_POI_object.features[i].properties.subtitles.length > 2) {
                            var level = All_POI_object.features[i].properties.Level;
                            var category_ar = "SPL Head Office";
                            if (All_POI_object.features[i].properties.category_id != null) {
                                category_ar = cateogry_array[All_POI_object.features[i].properties.category_id] + " - ";
                            }
                            var array_lev = Object.keys(level_array);
                            var floorid_;
                            var siz = array_lev.length;
                            for (var a = 0; a < siz; a++) {
                                if (level_array[array_lev[a]] == level) {
                                    floorid_ = array_lev[a];
                                    level = arabic_levels[level];
                                }
                            }

                            $('#TO_Location')
                                .append($("<option data-foo='" + category_ar + " " + level + "'>" + All_POI_object.features[i].properties.subtitles[2] + "</option>")
                                    .attr("value", All_POI_object.features[i].properties.Center[0] + "," + All_POI_object.features[i].properties.Center[1] + "," + floorid_)
                                );

                        }
                    }
                }
            }
        }

        //////////////////////////////////////////////////////////////// --- END --- ///////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////// *** LOAD MAP Data : buildings, floors , POIs , Routes , Beacons , Triggers *** ///////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////



        //////////////////////////////////////////////////////////////// --- START --- /////////////////////////////////////////////////////////////////////////////
        /////////////////////////////////                              *** MAP Events ***                                ///////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        // 1 - LOAD EVENT
        // map.on('load', () =>
        //     get_Authentication(),
        //     hide_screen_saver()
        //     // map.setLayoutProperty("building","visibility","none"),
        //     // map.setLayoutProperty("building-line","visibility","none")

        //    , map.addSource("buildingb", {
        //             type: "geojson",
        //             data: JSON.parse(other_buildings),
        //         }),


        //         map.addLayer({
        //             'id': "buildingb",
        //             'type': 'fill-extrusion',
        //             'maxzoom': 17.4,
        //             'source': "buildingb",
        //             'paint': {
        //                 'fill-extrusion-color': '#F5F5F5',
        //                 'fill-extrusion-height': 15,
        //                 'fill-extrusion-opacity': 0.85

        //             }
        //         })
        // );


        map.on('style.load', function () {
            map.style._mergedLayers["3d-buildingbasemap"].maxzoom = 17
        });


        map.on('load', () => {

            //map.setLayoutProperty("building", 'visibility', 'none');
            //map.setLayoutProperty("building-line", 'visibility', 'none');
            hide_screen_saver();
            get_Authentication();





            map.addSource("otherbuildings", {
                type: "geojson",
                data: JSON.parse(other_buildings),
            });


            map.addLayer({
                'id': "other_buildings",
                'type': 'fill-extrusion',
                'maxzoom': 17.4,
                'source': "otherbuildings",
                'paint': {
                    'fill-extrusion-color': '#F7F1E5',
                    'fill-extrusion-height': 10,
                    'fill-extrusion-opacity': 0.85

                }
            });


            map.addSource("psy_building", {
                type: "geojson",
                data: JSON.parse(psy_building),
            });


            map.addLayer({
                'id': "psy_building",
                'type': 'fill-extrusion',
                'maxzoom': 17.4,
                'source': "psy_building",
                'paint': {
                    'fill-extrusion-color': '#F7F1E5',
                    'fill-extrusion-height': 10,
                    'fill-extrusion-opacity': 0.85

                }
            });


            map.addSource("building_50", {
                type: "geojson",
                data: JSON.parse(building_50),
            });


            map.addLayer({
                'id': "building_50",
                'type': 'fill-extrusion',
                'maxzoom': 17.4,
                'source': "building_50",
                'paint': {
                    'fill-extrusion-color': '#F7F1E5',
                    'fill-extrusion-height': 10,
                    'fill-extrusion-opacity': 0.85

                }
            });


            map.addSource("dental", {
                type: "geojson",
                data: JSON.parse(dental),
            });


            map.addLayer({
                'id': "dental",
                'type': 'fill-extrusion',
                'maxzoom': 17.4,
                'source': "dental",
                'paint': {
                    'fill-extrusion-color': '#F7F1E5',
                    'fill-extrusion-height': 15,
                    'fill-extrusion-opacity': 0.85

                }
            });


            map.addSource("main_building", {
                type: "geojson",
                data: JSON.parse(main_building),
            });


            map.addLayer({
                'id': "main_building",
                'type': 'fill-extrusion',
                'maxzoom': 17.4,
                'source': "main_building",
                'paint': {
                    'fill-extrusion-color': '#F7F1E5',
                    'fill-extrusion-height': 15,
                    'fill-extrusion-opacity': 0.85

                }
            });


            map.addSource("main_upper", {
                type: "geojson",
                data: JSON.parse(main_upper),
            });


            map.addLayer({
                'id': "main_upper",
                'type': 'fill-extrusion',
                'maxzoom': 17.4,
                'source': "main_upper",
                'paint': {
                    'fill-extrusion-base': 10,
                    'fill-extrusion-color': '#F7F1E5',
                    'fill-extrusion-height': 50,
                    'fill-extrusion-opacity': 0.85

                }
            });

            // setTimeout(() => {
            //     map.moveLayer("other_buildings");
            //     map.moveLayer("psy_building");
            //     map.moveLayer("building_50");
            //     map.moveLayer("dental");
            //     map.moveLayer("main_building");
            //     map.moveLayer("main_upper");
            // }, 5000);

        });



        function calculateDirection(lat1, lon1, lat2, lon2) {
            if (lat2 > lat1) {
                if (lon2 > lon1) {
                    return "Northeast";
                } else if (lon2 < lon1) {
                    return "Northwest";
                } else {
                    return "North";
                }
            } else if (lat2 < lat1) {
                if (lon2 > lon1) {
                    return "Southeast";
                } else if (lon2 < lon1) {
                    return "Southwest";
                } else {
                    return "South";
                }
            } else {
                if (lon2 > lon1) {
                    return "East";
                } else if (lon2 < lon1) {
                    return "West";
                } else {
                    return "Same direction";
                }
            }
        }




        function calculateBearing(lat1, lon1, lat2, lon2) {
            const dLon = lon2 - lon1;
            const y = Math.sin(dLon) * Math.cos(lat2);
            const x = Math.cos(lat1) * Math.sin(lat2) - Math.sin(lat1) * Math.cos(lat2) * Math.cos(dLon);
            const brng = Math.atan2(y, x);
            return (brng >= 0 ? brng : (2 * Math.PI + brng)) * (180 / Math.PI);
        }


        function calculateBearing_v2(lat1, lon1, lat2, lon2) {
            const φ1 = lat1 * Math.PI / 180;
            const φ2 = lat2 * Math.PI / 180;
            const Δλ = (lon2 - lon1) * Math.PI / 180;

            const y = Math.sin(Δλ) * Math.cos(φ2);
            const x = Math.cos(φ1) * Math.sin(φ2) -
                Math.sin(φ1) * Math.cos(φ2) * Math.cos(Δλ);
            let brng = Math.atan2(y, x) * 180 / Math.PI;

            brng = (brng + 360) % 360;

            return brng;
        }
        function getUserGuideInstructions(routeCoordinates) {

            const instructions = [];

            Route_ins_lgn = new Array();
            Route_ins_lat = new Array();
            var prev_bering;
            for (let m = 0; m < routeCoordinates.features[0].geometry.coordinates.length - 1; m++) {
                if (m == 0) {
                    Route_ins_lgn.push(parseFloat(routeCoordinates.features[0].geometry.coordinates[m][0]));
                    Route_ins_lat.push(parseFloat(routeCoordinates.features[0].geometry.coordinates[m][1]))


                    const bearing = calculateBearing(
                        parseFloat(routeCoordinates.features[0].geometry.coordinates[m][1]),
                        parseFloat(routeCoordinates.features[0].geometry.coordinates[m][0]),
                        parseFloat(routeCoordinates.features[0].geometry.coordinates[m + 1][1]),
                        parseFloat(routeCoordinates.features[0].geometry.coordinates[m + 1][0])
                    );
                    prev_bering = bearing;
                } else {
                    const bearing = calculateBearing(
                        parseFloat(routeCoordinates.features[0].geometry.coordinates[m][1]),
                        parseFloat(routeCoordinates.features[0].geometry.coordinates[m][0]),
                        parseFloat(routeCoordinates.features[0].geometry.coordinates[m + 1][1]),
                        parseFloat(routeCoordinates.features[0].geometry.coordinates[m + 1][0]));

                    if (Math.abs(bearing - prev_bering) > 45) {
                        Route_ins_lgn.push(parseFloat(routeCoordinates.features[0].geometry.coordinates[m][0]));
                        Route_ins_lat.push(parseFloat(routeCoordinates.features[0].geometry.coordinates[m][1]));
                        prev_bering = bearing;
                    }
                }
            }
            var lengut = routeCoordinates.features[0].geometry.coordinates.length;
            Route_ins_lgn.push(routeCoordinates.features[0].geometry.coordinates[lengut - 1][0]);
            Route_ins_lat.push(routeCoordinates.features[0].geometry.coordinates[lengut - 1][1]);

            for (var x = 0; x < Route_ins_lgn.length; x++) {
                var marker = new mapboxgl.Marker({
                    color: 'red'
                }).setLngLat([Route_ins_lgn[x], Route_ins_lat[x]]).addTo(map);

                //console.log("[" + Route_ins_lgn[x] + "," + Route_ins_lat[x] + "],")
            }


            for (let i = 0; i < Route_ins_lgn.length - 2; i++) {

                const bearing1 = calculateBearing(
                    Route_ins_lat[i],
                    Route_ins_lgn[i],
                    Route_ins_lat[i + 1],
                    Route_ins_lgn[i + 1]
                );


                const bearing2 = calculateBearing(
                    Route_ins_lat[i + 1],
                    Route_ins_lgn[i + 1],
                    Route_ins_lat[i + 2],
                    Route_ins_lgn[i + 2]
                );

                let turnInstruction;
                const angleDiff = (bearing2 - bearing1 + 360) % 360;
                //console.log("angleDiff : " + angleDiff);
                if (angleDiff < 90) {
                    turnInstruction = "Turn left";
                } else if (angleDiff > 270) {
                    turnInstruction = "Turn right";
                } else {
                    turnInstruction = "Continue straight";
                }

                const distance = getDistanceFromLatLonInKm(
                    parseFloat(Route_ins_lat[i]),
                    parseFloat(Route_ins_lgn[i]),
                    parseFloat(Route_ins_lat[i + 1]),
                    parseFloat(Route_ins_lgn[i + 1])
                );

                instructions.push(`${turnInstruction} after ${distance} meters.`);
            }

            return instructions;

        }


        function getNavigationInstructions(routeCoordinates) {
            // Initialize variables to store distance and instructions
            let totalDistance = 0;
            let instructions = [];


            Route_ins_lgn = new Array();
            Route_ins_lat = new Array();
            var prev_bering;
            for (let m = 0; m < routeCoordinates.features[0].geometry.coordinates.length - 1; m++) {
                if (m == 0) {
                    Route_ins_lgn.push(parseFloat(routeCoordinates.features[0].geometry.coordinates[m][0]));
                    Route_ins_lat.push(parseFloat(routeCoordinates.features[0].geometry.coordinates[m][1]))


                    const bearing = calculateBearing(
                        parseFloat(routeCoordinates.features[0].geometry.coordinates[m][1]),
                        parseFloat(routeCoordinates.features[0].geometry.coordinates[m][0]),
                        parseFloat(routeCoordinates.features[0].geometry.coordinates[m + 1][1]),
                        parseFloat(routeCoordinates.features[0].geometry.coordinates[m + 1][0])
                    );
                    prev_bering = bearing;
                } else {
                    const bearing = calculateBearing(
                        parseFloat(routeCoordinates.features[0].geometry.coordinates[m][1]),
                        parseFloat(routeCoordinates.features[0].geometry.coordinates[m][0]),
                        parseFloat(routeCoordinates.features[0].geometry.coordinates[m + 1][1]),
                        parseFloat(routeCoordinates.features[0].geometry.coordinates[m + 1][0]));

                    if (Math.abs(bearing - prev_bering) > 45) {
                        Route_ins_lgn.push(parseFloat(routeCoordinates.features[0].geometry.coordinates[m][0]));
                        Route_ins_lat.push(parseFloat(routeCoordinates.features[0].geometry.coordinates[m][1]));
                        prev_bering = bearing;
                    }
                }
            }
            var lengut = routeCoordinates.features[0].geometry.coordinates.length;
            Route_ins_lgn.push(routeCoordinates.features[0].geometry.coordinates[lengut - 1][0]);
            Route_ins_lat.push(routeCoordinates.features[0].geometry.coordinates[lengut - 1][1]);

            for (var x = 0; x < Route_ins_lgn.length; x++) {
                var marker = new mapboxgl.Marker({
                    color: 'red'
                }).setLngLat([Route_ins_lgn[x], Route_ins_lat[x]]).addTo(map);

                //console.log("[" + Route_ins_lgn[x] + "," + Route_ins_lat[x] + "],")
            }


            // Loop through the route points
            for (let i = 0; i < Route_ins_lgn.length - 1; i++) {


                // Calculate the distance between consecutive points
                const distance = getDistanceFromLatLonInKm(Route_ins_lat[i + 1], Route_ins_lgn[i + 1], Route_ins_lat[i], Route_ins_lgn[i]);

                // Update total distance
                totalDistance += distance;

                // Determine the direction based on the relative positions of consecutive points
                let direction = "";

                const bearing = calculateBearing_v2(Route_ins_lgn[i], Route_ins_lat[i], Route_ins_lgn[i + 1], Route_ins_lat[i + 1]);

                var turn_side = (Route_ins_lgn[i + 1] - Route_ins_lgn[i - 1]) * (Route_ins_lat[i] - Route_ins_lat[i - 1]) - (Route_ins_lat[i + 1] - Route_ins_lat[i - 1]) * (Route_ins_lgn[i] - Route_ins_lgn[i - 1])
                console.info("Turn Side : " + turn_side);
                if (turn_side > 0) {
                    console.info("Turn Right");
                } else {
                    console.info("Tuen Left");
                }

                if (bearing >= 0 && bearing < 45) {
                    direction += `Move forward ${distance.toFixed(2)} meters, then turn right.`;
                } else if (bearing >= 45 && bearing < 135) {
                    direction += `Move forward ${distance.toFixed(2)} meters, then continue straight.`;
                } else if (bearing >= 135 && bearing < 225) {
                    direction += `Move forward ${distance.toFixed(2)} meters, then turn left.`;
                } else if (bearing >= 225 && bearing < 315) {
                    direction += `Move forward ${distance.toFixed(2)} meters, then continue straight.`;
                } else {
                    direction += `Move forward ${distance.toFixed(2)} meters, then turn right.`;
                }

                // Add the direction to the instructions
                instructions.push(direction);
            }

            // console.log("*************************************************");
            // console.log("*************** totalDistance *******************");
            // console.log("************** " + totalDistance + "*****************");
            // console.log(instructions);

            // Return the total distance and instructions
            return {
                totalDistance: totalDistance,
                instructions: instructions
            };
        }


        // 
        map.on('click', function (ev) {
            //console.log('set_postion( ' + ev.lngLat.lng + ',  ' + ev.lngLat.lat + ' ,425);');
            if (move_to_location_flag) {
                var lvl;
                if (Level_route_poi == 0) {
                    lvl = 2;
                } else if (Level_route_poi == -1) {
                    lvl = 1;
                }
                else if (Level_route_poi == 1) {
                    lvl = 3;
                }
                else if (Level_route_poi == 4) {
                    lvl = 4;
                }
                else if (Level_route_poi == 5) {
                    lvl = 5;
                }
                else if (Level_route_poi == 6) {
                    lvl = 6;
                }
                else if (Level_route_poi == 7) {
                    lvl = 7;
                }
                // console.log('set_postion( ' + ev.lngLat.lng + ',  ' + ev.lngLat.lat + ' ,'+lvl+');');
                current_lvl = lvl;
                set_postion(ev.lngLat.lng, ev.lngLat.lat, lvl);
                switch_to_current_floor();
                move_to_location_flag = false;
            }
        });

        // let lastClickedRoomId = null;
        // map.on('click', '100/0/rooms', function (ev) {
        //     console.log(ev);

        //     const clickedRoomId = ev.features[0].properties.id; // Assuming each room has a unique 'id' property

        // // Reset the previous room to normal color if any
        // if (lastClickedRoomId !== null && lastClickedRoomId !== clickedRoomId) {
        //     map.setPaintProperty(
        //         '100/0/rooms',
        //         'fill-extrusion-color',
        //         ['case', ['==', ['get', 'id'], lastClickedRoomId], '#888888', ['get', 'color']]
        //     );
        // }

        // // Change clicked room color to purple
        // map.setPaintProperty(
        //     '100/0/rooms',
        //     'fill-extrusion-color',
        //     ['case', ['==', ['get', 'id'], clickedRoomId], '#800080', ['get', 'color']]
        // );

        // // Update the last clicked room id
        // lastClickedRoomId = clickedRoomId;

        //     map.flyTo({
        //     center: [ev.lngLat.lng, ev.lngLat.lat],
        //     essential: true // this animation is considered essential with respect to prefers-reduced-motion
        //     });
        // });


        let lastClickedRoomId = null
        var xx;

        function isArraySubset(A, B) {
            return A.every(element => B.includes(element));
        }


        function clear_filter() {
            const features = map.getSource("municipalities")._data.features;
            features.forEach((feature) => {
                map.setFeatureState(
                    { source: 'municipalities', id: feature.id },
                    { selected: false }
                );
            });
        }

        function highlightMatchingPolygons(array_of_subs) {
            clear_filter();
            const features = map.getSource("municipalities")._data.features;
            features.forEach((feature) => {
                const subtitles = feature.properties.subtitles;
                if (subtitles.length > 0) {
                    var match = isArraySubset(array_of_subs, subtitles);
                    map.setFeatureState(
                        { source: 'municipalities', id: feature.id },
                        { selected: match }
                    );
                }
            });
            //map.setCenter([55.2878815342813,25.224059567554903]);
            // map.flyTo({
            //     center: [ 55.287815434822676, 25.224190647389037],
            //     duration: 2000,
            //     zoom : 18.196819917734842,
            //     pitch:37,
            //     essential: true // this animation is considered essential with respect to prefers-reduced-motion
            // });            
            // map.rotateTo(32.140743552789445, { // Rotate to 45 degrees
            // duration: 2000,  // 2000 milliseconds (2 seconds)
            // easing: function(t) { return t; } // Optional easing function
            // });
        }

        var poi_id = -1;
        var poi_route_id = -1;

        function get_direction() {
            ClearRoute();
            poi_route_id = poi_id;
            draw_path_to_poi(
                change_name,
                parseFloat(change_lg),
                parseFloat(change_lt),
                change_lvl,
                change_icon,
                change_selected_poi
            );
        }

        // 3 - click polygons event
        map.on('click', 'polygons', function (ev) {
            clear_filter();
            document.getElementsByClassName("filter-container")[0].style.display = "none";
            xx = ev.features[0];
            const clickedRoomId = xx.id;
            poi_id = xx.id;
            journy_info(global_name, global_distance, global_time, global_zlevel, global_icon);
            if (lastClickedRoomId !== null && lastClickedRoomId !== clickedRoomId) {
                map.setFeatureState(
                    { source: 'municipalities', id: lastClickedRoomId },
                    { selected: false }
                );
            }

            // Highlight the currently clicked feature
            map.setFeatureState(
                { source: 'municipalities', id: clickedRoomId },
                { selected: true }
            );

            // Update the last clicked room id
            lastClickedRoomId = clickedRoomId;

            map.flyTo({
                center: [ev.lngLat.lng, ev.lngLat.lat],
                duration: 3000,
                essential: true // this animation is considered essential with respect to prefers-reduced-motion
            });


            // for(var x = 0 ; x < All_POI_object.features.length ; x++)
            // {
            //     if(clickedRoomId == All_POI_object.features[x].id)
            //     {
            //         //console.log(All_POI_object.features[x].geometry.coordinates);
            //         //get_area(All_POI_object.features[x].geometry.coordinates);
            //         if(All_POI_object.features[x].properties.subtitles.length > 0)
            //         {
            //             console.log("Area : "+All_POI_object.features[x].properties.subtitles[0]+" meters");
            //         }
            //     }
            // }


            var sub = JSON.parse(xx.properties.subtitles);

            document.getElementsByClassName("card")[0].style.display = "block";
            const div = document.getElementsByClassName('card');
            
            div[0].style.opacity = '1'; // Fade out
            div[0].style.transform = 'translateX(1px)';

            var btn_show = document.getElementById("show_card_btn");
            btn_show.style.display = "none";

            if (xx.properties.icon_url != '') {
                document.getElementById("img_card").src = xx.properties.icon_url;
            } else {
                if (xx.properties.title == "") {
                    document.getElementById("img_card").src = './images/booth.png';
                } else {
                    document.getElementById("img_card").src = './images/gisec.jpg';
                }
            }

            if (xx.properties.title != '') {
                var sub = JSON.parse(xx.properties.subtitles);
                document.getElementById("title_card").innerHTML = xx.properties.title;
            }
            else {
                if (sub.length > 0) {
                    document.getElementById("title_card").innerHTML = "Booth Type : " + sub[0];
                } else {
                    document.getElementById("title_card").innerHTML = "Booth";
                }
            }

            if (sub.length > 1) {
                if (!sub[1].includes("SQM")) {
                    document.getElementById("desc_card").innerHTML = sub[1];
                } else {
                    document.getElementById("desc_card").innerHTML = "Area Size : " + sub[1] + " , Price : " + sub[2];
                }

            } else {
                document.getElementById("desc_card").innerHTML = "";
            }

            if (xx.properties.title.length == 0) {
                var poi_name = "Booth";
                document.getElementById("book_btn").style.visibility = "visible";
            } else {
                var poi_name = xx.properties.title;
                document.getElementById("book_btn").style.visibility = "hidden";

            }
            var split_location = xx.properties.Center;
            var splitter_location = split_location.split('","');
            var lg = splitter_location[0].split('["');
            var lt = splitter_location[1].split('"]');
            var lvl = xx.properties.Level;
            var icon_url = xx.properties.icon_url;
            var selected_poi = xx;
            
            document.getElementById("hall_no").innerHTML = get_terminal_name(parseFloat(lg[1]), parseFloat(lt[0]));

            // console.log(lg[1] + " , " + lt[0]);

            change_lg = lg[1];
            change_lt = lt[0];
            change_name = poi_name;
            change_lvl = lvl;
            change_icon = icon_url;
            change_selected_poi = selected_poi;

        });

        function close_routing() {
            ClearRoute();
            document.getElementsByClassName("card")[0].style.display = "none";
        }


        function get_area(coordinates) {
            const polygon = turf.polygon(coordinates);

            // Calculate area in square meters
            const area = turf.area(polygon);

            // Convert area to dimensions (e.g., 4m x 5m)
            const length = Math.sqrt(area);
            const width = area / length;
            //console.log(`Polygon clicked!\nArea: ${area.toFixed(2)} sq.m\nApprox Dimensions: ${length.toFixed(2)}m x ${width.toFixed(2)}m`);
        }

        // 3 - Rotate EVENT
        map.on('rotate', function (ev) {
            var anglevalue = map.getBearing();
            var prevHeading = ze;
            pointx.features[0].properties.heading = turf.bearingToAzimuth(prevHeading - anglevalue);
            map.getSource('pointx').setData(pointx);
            entered = false;
            isfirstt = true;
        });

        //////////////////////////////////////////////////////////////// ---  END  --- /////////////////////////////////////////////////////////////////////////////
        /////////////////////////////////                              *** MAP Events ***                                ///////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        function hide_screen_saver() {
            setTimeout(() => {
                var screensaver = document.getElementById("screensaver");
                screensaver.style.display = "none";
            }, 4000);
        }

        function change_dialog_destination() {
            document.getElementById("change_dialog").style.visibility = "hidden";
            ClearRoute();
            draw_path_to_poi(change_name, change_lg, change_lt, change_lvl, change_icon, change_selected_poi);
        }

        function close_change_dialog_destination() {
            document.getElementById("change_dialog").style.visibility = "hidden";
        }

        var instruction_reroute_distnace = false;

        function ClearRoute() {
            stopAnimation();
            route_array = [];
            routeEnabled = false;
            instruction_flag = false;
            instruction_reroute_flag = true;
            elevator_global_lng = "";
            elevator_global_lat = "";
            elevator_global_lvl = "";
            //poi_id  = -1; 
            poi_route_id = -1;

            // if (route_between_floors_flag) {
            //     if(popup =! undefined)
            //     {popup.remove();}
            // }

            if (popup_global == undefined) {
               // console.log("No popup marker !!!");
            } else {
                popup_global.remove();
            }

            route_between_floors_flag = false;

            var mapLayer = map.getLayer('route');
            if (typeof mapLayer !== 'undefined') {
                map.removeLayer("route");
                map.removeSource("route");

                map.removeLayer("route_another");
                map.removeSource("route_another");


                var route_outline = map.getLayer('route_outline');
                if (typeof route_outline !== 'undefined') {
                    map.removeLayer("route_outline");
                    map.removeSource("route_outline");
                }

                var route_another_outline = map.getLayer('route_another_outline');
                if (typeof route_outline !== 'undefined') {
                    map.removeLayer("route_another_outline");
                    map.removeSource("route_another_outline");
                }

                map.removeLayer("poi_fill");
                map.removeSource("poi_fill");

                map.removeLayer("poi_border");
                map.removeSource("poi_border");

                slct_marker.remove();
                Route_ins = new Array();
                prev_route_ins = new Array();
                Route_ins_lgn = new Array();
                Route_ins_lat = new Array();
                previns = "";
                // $("#current-step").html(instruction_text);
                // $(".instructions").hide();
            }
        }

        function highlight_poi(lng, lat, poi) {
            poi_fill_border(poi);
            slct_marker = new mapboxgl.Marker({
                color: 'orange'
            }).setLngLat([lng, lat]).addTo(map);
        }

        var full_distance_to_destination = 0;
        var full_time_to_destination = 0;
        var instruction_flag = false;
        var instruction_reroute_flag = true;
        var outbulding = false;


        function check_elevators_inside_building(curr_lng, curr_lat, dest_lng, dest_lat) {

            var current = turf.points([
                [curr_lng, curr_lat]
            ]);

            var destination = turf.points([
                [dest_lng, dest_lat]
            ]);

            var current_index = null;
            var destination_index = null;

            for (var i = 0; i < buildingslayers.length; i++) {
                var ptsWithin = turf.pointsWithinPolygon(current, buildingslayers[i]);

                if (ptsWithin.features.length > 0) {
                    // Inside  ...
                    current_index = i;
                }
                else {
                    // Outside ...
                }
            }


            for (var z = 0; z < buildingslayers.length; z++) {
                var ptsWithin = turf.pointsWithinPolygon(destination, buildingslayers[z]);

                if (ptsWithin.features.length > 0) {
                    // Inside  ...
                    destination_index = z;
                }
                else {
                    // Outside ...
                }
            }
            if (current_index == null) {
                return false;
            }
            else if (current_index == destination_index) {
                return true;
            }
            else {
                return false;
            }



        }


        function check_inside_building(curr_lng, curr_lat, curr_lvl, dest_lng, dest_lat, dest_lvl) {

            var current = turf.points([
                [curr_lng, curr_lat]
            ]);

            var destination = turf.points([
                [dest_lng, dest_lat]
            ]);

            var current_index = null;
            var destination_index = null;

            for (var i = 0; i < buildingslayers.length; i++) {
                var ptsWithin = turf.pointsWithinPolygon(current, buildingslayers[i]);

                if (ptsWithin.features.length > 0) {
                    // Inside  ...
                    current_index = i;
                }
                else {
                    // Outside ...
                }
            }


            for (var z = 0; z < buildingslayers.length; z++) {
                var ptsWithin = turf.pointsWithinPolygon(destination, buildingslayers[z]);

                if (ptsWithin.features.length > 0) {
                    // Inside  ...
                    destination_index = z;
                }
                else {
                    // Outside ...
                }
            }

            if (current_index == null) {
                return true;
            } else if (destination_index == null) {
                return true;
            }
            else if (current_index == destination_index) {
                return true;
            } else {
                if (curr_lvl == 0) {
                    return true;
                } else if (dest_lvl == 0) {
                    return true
                } else {
                    return false;
                }

            }



        }

        function draw_path_to_poi(poi_name, poi_lng, poi_lat, poi_zlevel, icon_url, select_poi) {
            instruction_flag = true;
            change_lg = poi_lng;
            change_lt = poi_lat;
            change_lvl = poi_zlevel;
            change_name = poi_name;
            change_icon = icon_url;
            selected_poi = select_poi;
            routeEnabled = true;
            // POI Marker
            if (!remove_extra_route_flag) {
                highlight_poi(poi_lng, poi_lat, select_poi);
            }

            var check_inside_building_flag = check_inside_building(blueDot.getLngLat().lng, blueDot.getLngLat().lat, current_lvl, change_lg, change_lt, change_lvl);

            // if (poi_zlevel != current_lvl && check_inside_building_flag) {
            //     console.log("REROUTE BETWEEN FLOORS")
            //     route_between_floors(poi_lng, poi_lat, poi_zlevel, poi_name, icon_url);
            // }else if(! check_inside_building_flag)
            // {
            //     route_between_buildings(poi_lng, poi_lat, poi_zlevel, poi_name, icon_url);
            // }
            if (true) {
                Full_path_route = {
                    'type': 'FeatureCollection',
                    'features': [{
                        'type': 'Feature',
                        'geometry': {
                            'type': 'LineString',
                            'coordinates': []
                        }
                    }]
                };

                var to_lng = poi_lng;
                var to_lat = poi_lat;
                var to_lvl = poi_zlevel;

                var bluedot_outside = false;
                var points = turf.points([
                    [blueDot.getLngLat().lng, blueDot.getLngLat().lat]
                ]);
                var ptsWithin = turf.pointsWithinPolygon(points, searchWithin);


                if (ptsWithin.features.length > 0) {
                    var from_lng = blueDot.getLngLat().lng;
                    var from_lat = blueDot.getLngLat().lat;
                    var from_lvl = current_lvl;
                }
                else {
                    if (getDistanceFromLatLonInKm(blueDot.getLngLat().lat, blueDot.getLngLat().lng, gate_lat, gate_lng) < getDistanceFromLatLonInKm(blueDot.getLngLat().lat, blueDot.getLngLat().lng, gate_lat_1, gate_lng_1)) {
                        var from_lng = gate_lng;
                        var from_lat = gate_lat;
                        var from_lvl = 0;
                    } else {
                        var from_lng = gate_lng_1;
                        var from_lat = gate_lat_1;
                        var from_lvl = 0;
                    }
                    bluedot_outside = true;
                }

                //Minimum Distance Flag
                var min_flag = 0;
                var minumum_from;
                var minumum_to;

                //key for Start & end location
                var start_key;
                var end_key;

                for (var key in Routes_array) {
                    // Get
                    var value = Routes_array[key];
                    var spiltter = value.split(',');
                    var check_near_lgn = spiltter[0];
                    var check_near_lat = spiltter[1];
                    var level = spiltter[2];


                    // Comapre to find nearest waypoint to "From" & "To" location.
                    var min_distance_from = getDistanceFromLatLonInKm(check_near_lat, check_near_lgn, from_lat, from_lng);
                    var min_distance_to = getDistanceFromLatLonInKm(check_near_lat, check_near_lgn, to_lat, to_lng);


                    //first time assign the distance as a miniumm distance
                    if (min_flag == 0) {
                        min_flag = 1;
                        minumum_from = min_distance_from;
                        minumum_to = min_distance_to;
                        start_key = key;
                        end_key = key;
                    } else {
                        //compare to get minimum distance
                        if (level == from_lvl) {
                            if (minumum_from > min_distance_from) {
                                minumum_from = min_distance_from;
                                start_key = key;
                            }
                        }
                        if (level == to_lvl) {
                            if (minumum_to > min_distance_to) {
                                minumum_to = min_distance_to;
                                end_key = key;

                            }
                        }
                    }

                }

                // Create Geojson object to store route coordinates.
                var geojson = {
                    'type': 'FeatureCollection',
                    'features': [{
                        'type': 'Feature',
                        'geometry': {
                            'type': 'LineString',
                            'coordinates': []
                        }
                    }]
                };
                //pass grpah & start & end places to get shortest path
                Global_start_key = start_key;
                Global_end_key = end_key;
                shortestPath(graph, start_key, end_key);

                geojson.features[0].geometry.coordinates.push([blueDot.getLngLat().lng, blueDot.getLngLat().lat]);

                var full_distance = 0;
                var prefpointlng;
                var prevpointlat;
                for (var o = 0; o < route_array.length; o++) {
                    var waypoint = Routes_array[route_array[o]];
                    var array_coordinates = waypoint.split(',');
                    var lgn = array_coordinates[0];
                    var lat = array_coordinates[1];
                    var level = array_coordinates[2];

                    if (o == 0) {
                        init_route_lat = lat;
                        init_route_lng = lgn;
                        if (!bluedot_outside) {
                            full_distance = full_distance + getDistanceFromLatLonInKm(blueDot.getLngLat().lat, blueDot.getLngLat().lng, lat, lgn);
                        } else {
                            full_distance = full_distance + getDistanceFromLatLonInKm(from_lat, from_lng, lat, lgn);
                        }
                        prefpointlng = lgn;
                        prevpointlat = lat;
                        //bluedot_lnglat(lgn, lat);
                    } else if (o == 2) {
                        if (!bluedot_outside) {
                            full_distance = full_distance + getDistanceFromLatLonInKm(blueDot.getLngLat().lat, blueDot.getLngLat().lng, lat, lgn);
                        } else {
                            full_distance = full_distance + getDistanceFromLatLonInKm(from_lat, from_lng, lat, lgn);

                        }
                        second_route_lng = lgn;
                        second_route_lat = lat;
                        prefpointlng = lgn;
                        prevpointlat = lat;
                    } else {
                        full_distance = full_distance + getDistanceFromLatLonInKm(prevpointlat, prefpointlng, lat, lgn);
                        prefpointlng = lgn;
                        prevpointlat = lat;
                    }
                    Full_path_route.features[0].geometry.coordinates.push([lgn, lat]);
                    //insert the Route coordinates in the
                    if (level == Level_route_poi) {
                        geojson.features[0].geometry.coordinates.push([lgn, lat]);
                    }
                }
                full_distance_to_destination = full_distance;
                if (!remove_extra_route_flag) {
                    remove_route_layer();
                }
                var time = Math.floor(full_distance) / 74;
                full_time_to_destination = time;
                //journy_info(poi_name, Math.floor(full_distance), time, poi_zlevel, icon_url);
                global_name = poi_name;
                global_distance = Math.floor(full_distance);
                global_time = time;
                global_zlevel = poi_zlevel;
                global_icon = icon_url;
                Route_level();
                elevator_guide();
            }

        }

        function poi_fill_border(poi) {
            map.addSource("poi_fill", {
                type: "geojson",
                data: poi,
            });

            map.addLayer({
                id: "poi_fill",
                type: "fill",
                source: "poi_fill",
                'paint': {
                    'fill-color': "#FF7B00",
                    'fill-opacity': 0.3
                }
            });

            map.addSource("poi_border", {
                type: "geojson",
                data: poi,
            });

            map.addLayer({
                id: "poi_border",
                type: "line",
                source: "poi_border",
                'paint': {
                    'line-color': "#FF7B00",
                    'line-width': 3
                },
                'layout': {
                    'line-join': 'round',
                    'line-cap': 'round'
                }
            });
        }



        function journy_info(poi_name, distance, time, floor, icon_url) {

            if (poi_route_id == poi_id) {
                document.getElementsByClassName("journy_info_details")[0].style.display = "block";

                if (time < 1) {
                    time = time * 60;
                    time = Math.floor(time) + " sec"
                    document.getElementById("journy_info_duration").innerHTML = " Duration : " + time;
                    document.getElementById("p_time").innerHTML = time;
                } else {
                    time = Math.floor(time) + " min"
                    document.getElementById("journy_info_duration").innerHTML = " Duration : " + time;
                    document.getElementById("p_time").innerHTML = time;
                }
                if (distance > 1000) {
                    distance = (distance / 1000).toFixed(1);
                    document.getElementById("journy_info_distance").innerHTML = " Distance : " + distance + "  Km";
                    document.getElementById("p_distance").innerHTML = distance + " Km";

                }
                else {
                    document.getElementById("journy_info_distance").innerHTML = " Distance : " + distance + "  meter";
                    document.getElementById("p_distance").innerHTML = distance + " meters";
                }

                document.getElementById("journy_info_level").innerHTML = "Level : " + english_levels[floor];
                document.getElementById("p_floor").innerHTML = english_levels[floor];

            } else {

                document.getElementsByClassName("journy_info_details")[0].style.display = "none";

                var btn_distance = document.getElementById("btn_distance");
                btn_distance.style.display = "none";

                var btn_title = document.getElementById("btn_title");
                btn_title.style.display = "none";

                var btn_time = document.getElementById("btn_time");
                btn_time.style.display = "none";

                var btn_level = document.getElementById("btn_level");
                btn_level.style.display = "none";
            }

            // document.getElementById("myModal").style.display = "block";
            // document.getElementById("destination_name").innerHTML = poi_name;
            // document.getElementById("floorLabel").innerHTML = floor;
            // var img = document.getElementById("destination_img_test");
            // //
            // if (icon_url != "" && icon_url != undefined) {
            //     img.src = icon_url
            //     img.style.display = "block";
            // } else {
            //     img.style.display = "none";
            // }
        }


        function check_routing() {
            if (poi_route_id == poi_id) {
                document.getElementsByClassName("journy_info_details")[0].style.display = "block";

                if (time < 1) {
                    time = time * 60;
                    time = Math.floor(time) + " sec"
                    document.getElementById("journy_info_duration").innerHTML = "Duration : " + time;

                } else {
                    time = Math.floor(time) + " min"
                    document.getElementById("journy_info_duration").innerHTML = "Duration : " + time;
                }
                if (distance > 1000) {
                    distance = (distance / 1000).toFixed(1);
                    document.getElementById("journy_info_distance").innerHTML = "Distance : " + distance + " Km";;

                }
                else {
                    document.getElementById("journy_info_distance").innerHTML = "Distance : " + distance + " meter";;
                }

                document.getElementById("journy_info_level").innerHTML = "Leve : " + floor;
            } else {
                document.getElementsByClassName("journy_info_details")[0].style.display = "none";

            }

        }

        function current_location() {
            map.flyTo({
                center: [blueDot.getLngLat().lng, blueDot.getLngLat().lat],
                duration: 3000,
                zoom: 19.489296826958224,
            });
            switch_to_current_floor();
        }

        function switch_to_current_floor() {

            var menubtn = document.getElementById("menu");

            for (var i = 0; i < menubtn.childElementCount; i++) {
                var floor = menubtn.children[i].innerText;
                if (floor == "G") {
                    floor = 0;
                } else {
                    floor = parseInt(floor);
                }

                if (floor == current_lvl) {
                    if (current_lvl == Level_route_poi) {
                        map.flyTo({
                            center: [blueDot.getLngLat().lng, blueDot.getLngLat().lat],
                            zoom: 19.489296826958224,
                        });
                    } else {
                        menubtn.children[i].click();
                    }
                }
            }
        }

        function getDistanceFromLatLonInKm(lat1, lon1, lat2, lon2) {
            var R = 6371; // Radius of the earth in km
            var dLat = deg2rad(lat2 - lat1); // deg2rad below
            var dLon = deg2rad(lon2 - lon1);
            var a =
                Math.sin(dLat / 2) * Math.sin(dLat / 2) +
                Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2)) *
                Math.sin(dLon / 2) * Math.sin(dLon / 2);
            var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
            var d = R * c; // Distance in km
            return d * 1000;
        }

        function deg2rad(deg) {
            return deg * (Math.PI / 180)
        }

        //function to find shortest path
        function shortestPath(graph, source, target) {
            if (source == target) {
                return;
            }
            var queue = [source],
                visited = {
                    source: true
                },
                predecessor = {},
                tail = 0;
            while (tail < queue.length) {
                var u = queue[tail++],
                    neighbors = graph.neighbors[u];
                for (var i = 0; i < neighbors.length; ++i) {
                    var v = neighbors[i];
                    if (visited[v]) {
                        continue;
                    }
                    visited[v] = true;
                    if (v === target) {
                        var path = [v];
                        while (u !== source) {
                            path.push(u);
                            u = predecessor[u];
                        }
                        path.push(u);
                        path.reverse();
                        for (let index = 0; index < path.length; index++) {
                            route_array.push(path[index]);
                        }
                        return;
                    }
                    predecessor[v] = u;
                    queue.push(v);
                }
            }
        }

        var remove_extra_route_flag = false;

        var get_instructions_flag = false;

        var route_counter_inc = 0;

        async function Route_level() {

            route_counter_inc = 0;


            SmartRoute = {
                'type': 'FeatureCollection',
                'features': [{
                    'type': 'Feature',
                    "properties": {
                        "level": null,
                    },
                    'geometry': {
                        'type': 'LineString',
                        'coordinates': []
                    }
                }
                ]
            };


            Route_by_level = {
                'type': 'FeatureCollection',
                'features': [{
                    'type': 'Feature',
                    'geometry': {
                        'type': 'LineString',
                        'coordinates': []
                    }
                },
                {
                    'type': 'Feature',
                    'geometry': {
                        'type': 'LineString',
                        'coordinates': []
                    }
                }
                ]
            };

            Route_by_level_another = {
                'type': 'FeatureCollection',
                'features': [{
                    'type': 'Feature',
                    'geometry': {
                        'type': 'LineString',
                        'coordinates': []
                    }
                },
                {
                    'type': 'Feature',
                    'geometry': {
                        'type': 'LineString',
                        'coordinates': []
                    }
                }
                ]
            };



            if (route_array.length > 0) {
                var waypoint = Routes_array[route_array[0]];
                var array_coordinates = waypoint.split(',');
                var lgn = array_coordinates[0];
                var lat = array_coordinates[1];
                if (getDistanceFromLatLonInKm(blueDot.getLngLat().lat, blueDot.getLngLat().lng, lat, lgn) > 1000) {

                    if (getDistanceFromLatLonInKm(blueDot.getLngLat().lat, blueDot.getLngLat().lng, gate_lat, gate_lng) < getDistanceFromLatLonInKm(blueDot.getLngLat().lat, blueDot.getLngLat().lng, gate_lat_1, gate_lng_1)) {
                        await get_outside_route(gate_lng, gate_lat);

                    } else {
                        await get_outside_route(gate_lng_1, gate_lat_1);

                    }

                    for (var i = 0; i < outside_coordinates.coordinates.length; i++) {
                        if (Level_route_poi == 0) {
                            Route_by_level.features[0].geometry.coordinates.push([outside_coordinates.coordinates[i][0], outside_coordinates.coordinates[i][1]]);
                            ins_lng[route_counter_inc] = outside_coordinates.coordinates[i][0];
                            ins_lat[route_counter_inc] = outside_coordinates.coordinates[i][1];
                            route_counter_inc++;
                        } else {
                            Route_by_level_another.features[0].geometry.coordinates.push([outside_coordinates.coordinates[i][0], outside_coordinates.coordinates[i][1]]);
                        }


                    }

                    full_distance_to_destination = full_distance_to_destination + journy_outside_info.distance;
                    full_time_to_destination = (full_time_to_destination * 60 + journy_outside_info.duration) / 60;
                    journy_info(change_name, Math.floor(full_distance_to_destination), full_time_to_destination, change_lvl, change_icon);
                }
                else {
                    journy_info(global_name, global_distance, global_time, global_zlevel, global_icon);
                }
            }

            var entered = false
            var entered1 = false
            var pre_lng;
            var pre_lat;
            var pre_lvl;
            var SmartRoute_counter = 0
            for (var o = 0; o < route_array.length; o++) {
                var waypoint = Routes_array[route_array[o]];
                var array_coordinates = waypoint.split(',');
                var lgn = array_coordinates[0];
                var lat = array_coordinates[1];
                var level = array_coordinates[2];
                // var marker1 = new mapboxgl.Marker()
                // .setLngLat([lgn, lat])
                // .addTo(map);
                //insert the Route coordinates in the
                if (o == 0) {
                    // bluedot_lnglat(parseFloat(lgn), parseFloat(lat));
                    pre_lvl = level;
                    SmartRoute.features[SmartRoute_counter].properties.level = pre_lvl
                    SmartRoute.features[SmartRoute_counter].geometry.coordinates.push([blueDot.getLngLat().lng, blueDot.getLngLat().lat]);
                }
                else {

                    if (level == pre_lvl) {

                        SmartRoute.features[SmartRoute_counter].properties.level = pre_lvl
                        SmartRoute.features[SmartRoute_counter].geometry.coordinates.push([lgn, lat]);


                    } else {

                        SmartRoute_counter++;
                        pre_lvl = level;
                        SmartRoute.features[SmartRoute_counter] = {
                            'type': 'Feature',
                            "properties": {
                                "level": pre_lvl,
                            },
                            'geometry': {
                                'type': 'LineString',
                                'coordinates': [[lgn, lat]]
                            }
                        };

                    }

                }

                if (level == Level_route_poi) {
                    if (check_elevators_inside_building(blueDot.getLngLat().lng, blueDot.getLngLat().lat, lgn, lat)) {
                        var notclose = true
                        if (Route_by_level.features[0].geometry.coordinates.length > 0) {
                            var lastcord = Route_by_level.features[0].geometry.coordinates[Route_by_level.features[0].geometry.coordinates.length - 1];
                            if (getDistanceFromLatLonInKm(parseFloat(lastcord[1]), parseFloat(lastcord[0]), lat, lgn) > 1000) {
                                notclose = false;
                                continue;
                            }

                        }
                        Route_by_level.features[0].geometry.coordinates.push([lgn, lat]);
                        pre_lng = lgn;
                        pre_lat = lat;
                        entered = true

                    } else {
                        if (entered && current_lvl == 0) {
                            Route_by_level.features[1].geometry.coordinates.push([pre_lng, pre_lat]);
                            entered = false
                        }
                        Route_by_level.features[1].geometry.coordinates.push([lgn, lat]);
                    }
                }
                else {
                    if (check_elevators_inside_building(blueDot.getLngLat().lng, blueDot.getLngLat().lat, lgn, lat)) {
                        // var notclose = true
                        if (Route_by_level_another.features[0].geometry.coordinates.length > 0) {
                            var lastcord = Route_by_level_another.features[0].geometry.coordinates[Route_by_level_another.features[0].geometry.coordinates.length - 1];
                            if (getDistanceFromLatLonInKm(parseFloat(lastcord[1]), parseFloat(lastcord[0]), lat, lgn) > 10) {
                                notclose = false;
                                continue;
                            }

                        }
                        Route_by_level_another.features[0].geometry.coordinates.push([lgn, lat]);
                        pre_lng = lgn;
                        pre_lat = lat;
                        entered1 = true
                    } else {
                        // if(entered1 && current_lvl == 1)
                        // {
                        //     Route_by_level_another.features[1].geometry.coordinates.push([pre_lng, pre_lat]);
                        //     entered1 = false

                        // }

                        var notclose = true
                        if (Route_by_level_another.features[1].geometry.coordinates.length > 0) {
                            var lastcord = Route_by_level_another.features[1].geometry.coordinates[Route_by_level_another.features[1].geometry.coordinates.length - 1];
                            if (getDistanceFromLatLonInKm(parseFloat(lastcord[1]), parseFloat(lastcord[0]), lat, lgn) > 10) {
                                notclose = false;
                                continue;
                            }

                        }

                        Route_by_level_another.features[1].geometry.coordinates.push([lgn, lat]);
                    }
                }

                if (level == current_lvl) {
                    ins_lng[route_counter_inc] = lgn;
                    ins_lat[route_counter_inc] = lat;
                    route_counter_inc++;
                }
            }


            if (ins_lng !== undefined && get_instructions_flag) {
                get_instructions_flag = false;
                //console.error("************************ GET INSTRUCTIONS ************************");
                Route_ins = new Array();
                prev_route_ins = new Array();
                Route_ins_lgn = new Array();
                Route_ins_lat = new Array();
                previns = "";
                //get_instructions(ins_lng, ins_lat);
                // console.log(Route_ins);
            }

            if (!remove_extra_route_flag) {

                remove_route_layer();
                //shortestPath(graph, Global_start_key, Global_end_key);
                //geojson.features[0].geometry.coordinates.push([blueDot.getLngLat().lng, blueDot.getLngLat().lat]);

                map.addSource('route', {
                    'type': 'geojson',
                    'data': SmartRoute
                });

                map.addLayer({
                    'id': 'route',
                    'type': 'line',
                    'source': 'route',
                    'filter': ['==', 'level', Level_route_poi.toString()],
                    'layout': {
                        'line-join': 'round',
                        'line-cap': 'round'
                    },
                    'paint': {
                        'line-color': '#0099EA',
                        'line-width': 15
                        // 'line-pattern': "fast-forward.png"
                    }
                });

                map.addSource('route_outline', {
                    'type': 'geojson',
                    'data': SmartRoute
                });

                map.addLayer({
                    'id': 'route_outline',
                    'type': 'line',
                    'source': 'route_outline',
                    'filter': ['==', 'level', Level_route_poi.toString()],

                    'layout': {
                        'line-join': 'round',
                        'line-cap': 'round'
                    },
                    paint: {
                        "line-color": '#66c0f0',
                        'line-dasharray': [0, 4, 3],
                        "line-width": 9
                    }
                });

                // Enter The Whole Data room !!!
                // FoR SuRe ThE eNd oF ThIs eRa WiLL bE nIcE
                // TeST for the national page of the kinddomn

                map.addSource('route_another', {
                    'type': 'geojson',
                    'data': Route_by_level_another
                });

                map.addLayer({
                    'id': 'route_another',
                    'type': 'line',
                    'source': 'route_another',
                    'layout': {
                        'line-join': 'round',
                        'line-cap': 'round'
                    },
                    'paint': {
                        'line-color': '#BBBBBB',
                        'line-width': 9,
                        'line-opacity': 0.3
                        //'line-pattern': "fast-forward4.png"
                    }
                });

                map.addSource('route_another_outline', {
                    'type': 'geojson',
                    'data': Route_by_level_another
                });


                map.addLayer({
                    'id': 'route_another_outline',
                    'type': 'line',
                    'source': 'route_another_outline',
                    'layout': {
                        'line-join': 'round',
                        'line-cap': 'round'
                    },
                    'paint': {
                        'line-color': '#A5A4A4',
                        'line-width': 15,
                        'line-opacity': 0.3
                    }
                });

                map.moveLayer('route_another', 'mm-bluedot-circle1');
                map.moveLayer('route_another', 'mm-bluedot-accuracy1');
                map.moveLayer('route_another', 'pointx');

                map.moveLayer('route_another_outline', 'mm-bluedot-circle1');
                map.moveLayer('route_another_outline', 'mm-bluedot-accuracy1');
                map.moveLayer('route_another_outline', 'pointx');

                map.moveLayer('route', 'mm-bluedot-circle1');
                map.moveLayer('route', 'mm-bluedot-accuracy1');
                map.moveLayer('route', 'pointx');

                map.moveLayer('route_outline', 'mm-bluedot-circle1');
                map.moveLayer('route_outline', 'mm-bluedot-accuracy1');
                map.moveLayer('route_outline', 'pointx');

                map.moveLayer('route_another', 'route');


            } else {
                // console.log("Update Route !!!!");
                // console.log("Route Level : "+Route_by_level.features[0].geometry.coordinates.length);
                // console.log("Route Level Another : "+Route_by_level_another.features[0].geometry.coordinates.length);
                remove_extra_route_flag = false;
                var timer = window.setInterval(function () {
                    var mapLayer = map.getLayer('route');
                    var mapSource = map.getSource('route');
                    if (typeof mapSource !== 'undefined') {
                        map.getSource('route').setData(SmartRoute);
                        map.getSource('route_another').setData(SmartRoute);
                        map.getSource('route_outline').setData(SmartRoute);
                        map.getSource('route_another_outline').setData(SmartRoute);
                        window.clearInterval(timer);
                    }

                }, 100);
            }

            startAnimation();
            view_full_path();
        }

        function view_full_path()
       {
           if(SmartRoute.features[0].geometry.coordinates.length > 0 ){

               const coordinates = SmartRoute.features[0].geometry.coordinates;
               // Create a 'LngLatBounds' with both corners at the first coordinate.
               const bounds = new mapboxgl.LngLatBounds(
                   coordinates[0],
                   coordinates[0]
               );

               for (const coord of coordinates) {
                   bounds.extend(coord);
               }

               map.fitBounds(bounds, {
                   padding: 70,
                   pitch: 29.500000000000057,
                   bearing : map.getBearing()
               });


           }

       }


        const dashArraySequence = [
            [0, 4, 3],
            [0.5, 4, 2.5],
            [1, 4, 2],
            [1.5, 4, 1.5],
            [2, 4, 1],
            [2.5, 4, 0.5],
            [3, 4, 0],
            [0, 0.5, 3, 3.5],
            [0, 1, 3, 3],
            [0, 1.5, 3, 2.5],
            [0, 2, 3, 2],
            [0, 2.5, 3, 1.5],
            [0, 3, 3, 1],
            [0, 3.5, 3, 0.5]
        ];

        const workerCode_animation = "const dashArraySequence = [    [0, 4, 3],    [0.5, 4, 2.5],    [1, 4, 2],    [1.5, 4, 1.5],    [2, 4, 1],    [2.5, 4, 0.5],    [3, 4, 0],    [0, 0.5, 3, 3.5],    [0, 1, 3, 3],    [0, 1.5, 3, 2.5],    [0, 2, 3, 2],    [0, 2.5, 3, 1.5],    [0, 3, 3, 1],    [0, 3.5, 3, 0.5]];let step = 0;onmessage = function(e) {    const timestamp = e.data;    const newStep = parseInt((timestamp / 90) % dashArraySequence.length);    if (newStep !== step) {        postMessage(dashArraySequence[newStep]);        step = newStep;    }};";
        const blob_anim = new Blob([workerCode_animation], { type: 'application/javascript' });
        const anim_url = URL.createObjectURL(blob_anim);
        const Worker_animation = new Worker(anim_url);

        let worker;
        let isAnimating = false; // Control flag for animation
        let animationFrameId = null; // Store the animation frame ID for stopping

        function startAnimation() {
            if (!worker) {
                worker = new Worker(anim_url);

                worker.onmessage = function (e) {
                    const dashArray = e.data;
                    // Update the line-dasharray property on the map
                    map.setPaintProperty('route_outline', 'line-dasharray', dashArray);
                };
            }

            if (!isAnimating) {
                isAnimating = true;
                animateDashArray(0); // Start animation loop
            }
        }

        function stopAnimation() {
            isAnimating = false;

            if (animationFrameId) {
                cancelAnimationFrame(animationFrameId); // Stop the animation loop
                animationFrameId = null;
            }

            if (worker) {
                worker.terminate(); // Stop the worker
                worker = null;
            }
        }

        function animateDashArray(timestamp) {
            if (!isAnimating) return; // Stop animation if flag is false

            worker.postMessage(timestamp); // Send timestamp to worker
            animationFrameId = requestAnimationFrame(animateDashArray); // Request next frame
        }


        var prev_ele_lvl;
        var journy_Elevator = new Array();
        var journy_Elevator_occurance = new Array();
        var journy_one_elevator = new Array();
        var evelID = new Array();
        var evelgt = new Array();
        var evelat = new Array();
        var evelvl = new Array();
        var evenext = new Array();
        var evevisited = new Array();
        var evecounter = 0;

        function elevator_guide() {
            evelID = new Array();
            evelgt = new Array();
            evelat = new Array();
            evelvl = new Array();
            evenext = new Array();
            journy_Elevator = new Array();
            journy_Elevator_occurance = new Array();
            journy_one_elevator = new Array();

            evecounter = 0;

            for (var i = 0; i < route_array.length; i++) {
                var wa = Routes_array[route_array[i]];
                var arr = wa.split(',');
                var lv = arr[2];
                journy_Elevator[i] = lv;
            }
            journy_Elevator_occurance = _.countBy(journy_Elevator);
            journy_Elevator = _.uniq(journy_Elevator);

            for (var x = 0; x < journy_Elevator.length; x++) {
                //console.log(journy_Elevator_occurance[journy_Elevator[x]]);
                if (journy_Elevator_occurance[journy_Elevator[x]] == 1) {
                    journy_one_elevator.push(journy_Elevator[x]);
                }
            }

            for (var o = 0; o < route_array.length; o++) {
                var waypoint = Routes_array[route_array[o]];
                var array_coordinates = waypoint.split(',');
                var lgn = array_coordinates[0];
                var lat = array_coordinates[1];
                var level = array_coordinates[2];

                if (o == 0) {
                    prev_ele_lvl = level;
                }
                else {
                    if (prev_ele_lvl != level) {
                        if (!(journy_one_elevator.includes(level + ''))) {
                            var w = Routes_array[route_array[o - 2]];
                            var ar = w.split(',');
                            var lg = ar[0];
                            var lt = ar[1];
                            var lvl = ar[2];
                            evelID.push(lg + lt);
                            evelgt.push(lg);
                            evelat.push(lt);
                            evelvl.push(lvl);
                            evenext.push(level);
                            prev_ele_lvl = level;
                        }

                    }
                }
            }

            if (routeEnabled && evelgt.length > 0) {

                for (var x = 0; x < evelvl.length; x++) {
                    if (Level_route_poi == parseInt(evelvl[x])) {
                        if (language == "AR") {
                            if (parseInt(evenext[x]) > parseInt(evelvl[x])) {
                                popup_global = new mapboxgl.Popup({ closeOnClick: false })
                                    .setLngLat([parseFloat(evelgt[x]), parseFloat(evelat[x])])
                                    .setHTML('<p style ="font-style: italic;font-family: monospace; color:white; font-size: 11px ; margin: auto;margin-top: 6px;"><i class="fa-solid fa-elevator"></i> Go to floor ' + evenext[x] + ' <i class="fa-solid fa-circle-up"></i></p>')
                                    .addTo(map);
                                break;
                            } else {
                                popup_global = new mapboxgl.Popup({ closeOnClick: false })
                                    .setLngLat([parseFloat(evelgt[x]), parseFloat(evelat[x])])
                                    .setHTML('<p style ="font-style: italic;font-family: monospace; color:white; font-size: 11px ; margin: auto;margin-top: 6px;"><i class="fa-solid fa-elevator"></i> Go to floor ' + evenext[x] + ' <i class="fa-solid fa-circle-down"></i></p>')
                                    .addTo(map);
                                break;
                            }
                        } else {
                            if (parseInt(evenext[x]) > parseInt(evelvl[x])) {
                                popup_global = new mapboxgl.Popup({ closeOnClick: false })
                                    .setLngLat([parseFloat(evelgt[x]), parseFloat(evelat[x])])
                                    .setHTML('<p style ="font-style: italic;font-family: monospace; color:white; font-size: 11px ; margin: auto;margin-top: 6px;"><i class="fa-solid fa-elevator"></i> Go to floor ' + evenext[x] + ' <i class="fa-solid fa-circle-up"></i></p>')
                                    .addTo(map);
                                break;
                            } else {
                                popup_global = new mapboxgl.Popup({ closeOnClick: false })
                                    .setLngLat([parseFloat(evelgt[x]), parseFloat(evelat[x])])
                                    .setHTML('<p style ="font-style: italic;font-family: monospace; color:white; font-size: 11px ; margin: auto;margin-top: 6px;"><i class="fa-solid fa-elevator"></i> Go to floor ' + evenext[x] + ' <i class="fa-solid fa-circle-down"></i></p>')
                                    .addTo(map);
                                break;
                            }
                        }

                    }
                    else {
                        if (popup_global == undefined) {
                            //console.log("No popup marker !!!");
                        } else {
                            popup_global.remove();
                        }
                    }
                }
            }
        }

        function get_instructions(Routeslng, Routeslat) {
            instruction_text = "";
            distance_instruction = 0;
            Route_ins = new Array();

            Route_ins_lgn = new Array();
            Route_ins_lat = new Array();

            Routeslng = _.uniq(Routeslng);
            Routeslat = _.uniq(Routeslat);

            for (var j = 0; j < Routeslng.length; j++) {
                for (var z = 0; z < Routeslng.length; z++) {
                    if ((z != j) && getDistanceFromLatLonInKm(Routeslat[j], Routeslng[j], Routeslat[z], Routeslng[z]) < 0.1) {
                        Routeslat.splice(z, 1);
                        Routeslng.splice(z, 1);
                    }
                }
            }

            var f = true;
            for (var i = 0; i < Routeslng.length; i++) {
                if (f) {
                    f = false;
                    i = 0;
                    if ((i + 1) < Routeslng.length) {
                        if (Routeslng[i] !== undefined) {
                            var from = turf.point([Routeslng[i], Routeslat[i]]);
                            var to = turf.point([Routeslng[i + 1], Routeslat[i + 1]]);
                            prev_bearing_ins = turf.rhumbBearing(from, to);
                            distance_instruction = distance_instruction + turf.rhumbDistance(from, to);
                            Route_ins_lgn.push(Routeslng[0]);
                            Route_ins_lat.push(Routeslat[0]);
                        }
                    }
                }
                else {
                    if ((i + 1) < Routeslng.length) {
                        if (Routeslng[i] !== undefined) {
                            var from1 = turf.point([Routeslng[i], Routeslat[i]]);
                            var to1 = turf.point([Routeslng[i + 1], Routeslat[i + 1]]);
                            current_bearing_ins = turf.rhumbBearing(from1, to1);

                            if (Math.abs(turf.bearingToAngle(prev_bearing_ins) - turf.bearingToAngle(current_bearing_ins)) < 60) {
                                prev_bearing_ins = current_bearing_ins;
                                distance_instruction = distance_instruction + turf.rhumbDistance(from1, to1);
                            }
                            else if (Math.abs(turf.bearingToAngle(prev_bearing_ins) - turf.bearingToAngle(current_bearing_ins)) > 60) {
                                if ((i - 1) >= 0) {
                                    prev_bearing_ins = current_bearing_ins;
                                    var turn_side = (Routeslng[i + 1] - Routeslng[i - 1]) * (Routeslat[i] - Routeslat[i - 1]) - (Routeslat[i + 1] - Routeslat[i - 1]) * (Routeslng[i] - Routeslng[i - 1])
                                    if (turn_side > 0) {
                                        if (Math.ceil(distance_instruction * 1000) == 0) {
                                            //                                            if(language == "EN")
                                            //                                            {
                                            //                                            instruction_text = instruction_text + "Move forword 1 meter & turn Right";
                                            //                                            Route_ins.push("Walk forword 1 meter and turn Right");
                                            //                                            }else
                                            //                                            {
                                            //                                              instruction_text = instruction_text + "التوجه للأمام مسافة متر ثم الي اليمين";
                                            //                                              Route_ins.push("التوجه للأمام مسافة متر ثم الي اليمين");
                                            //                                            }
                                            //
                                            //                                            distance_instruction = 0;
                                            //                                            Route_ins_lgn.push(Routeslng[i]);
                                            //                                            Route_ins_lat.push(Routeslat[i]);
                                        }
                                        else {

                                            if (language == "EN") {
                                                instruction_text = instruction_text + " Move forword  " + Math.ceil(distance_instruction * 1000) + " meter & turn Right";
                                                Route_ins.push("Walk forword  " + Math.ceil(distance_instruction * 1000) + " meter and turn Right");
                                            } else {
                                                instruction_text = instruction_text + "التوجه للامام مسافة  " + Math.ceil(distance_instruction * 1000) + " ثم الي اليمين";
                                                Route_ins.push(" التوجه للامام مسافة " + Math.ceil(distance_instruction * 1000) + " متر ثم الي اليمين");
                                            }

                                            Route_ins_lgn.push(Routeslng[i]);
                                            Route_ins_lat.push(Routeslat[i]);
                                            distance_instruction = 0;
                                        }

                                    }
                                    else if (turn_side < 0) {
                                        if (Math.ceil(distance_instruction * 1000) == 0) {
                                            //                                            if(language == "EN"){
                                            //                                                instruction_text = instruction_text + " Move forword 1 meter & turn Left";
                                            //                                                Route_ins.push("Wall forword 1 meter and turn Left");
                                            //                                            }else{
                                            //                                            instruction_text = instruction_text + " التوجه للامام متر ثم الي اليسار";
                                            //                                            Route_ins.push(" التوجه للامام متر ثم الي اليسار");
                                            //                                            }
                                            //                                            Route_ins_lgn.push(Routeslng[i]);
                                            //                                            Route_ins_lat.push(Routeslat[i]);
                                            //                                            distance_instruction = 0;
                                        }
                                        else {
                                            if (language == "EN") {
                                                Route_ins.push("Walk forword  " + Math.ceil(distance_instruction * 1000) + " meter and turn Left");
                                            } else {
                                                Route_ins.push("التوجه للامام مسافة" + Math.ceil(distance_instruction * 1000) + " متر ثم الي اليسار");
                                            }
                                            Route_ins_lgn.push(Routeslng[i]);
                                            Route_ins_lat.push(Routeslat[i]);
                                            distance_instruction = 0;
                                        }
                                    }
                                }
                            }
                        }
                    } else {
                        if (Routeslng[i] !== undefined) {
                            var from1 = turf.point([Routeslng[i], Routeslat[i]]);
                            var to1 = turf.point([Routeslng.length - 1, Routeslat.length - 1]);
                            current_bearing_ins = turf.rhumbBearing(from1, to1);

                            if (Math.abs(turf.bearingToAngle(prev_bearing_ins) - turf.bearingToAngle(current_bearing_ins)) < 60) {
                                prev_bearing_ins = current_bearing_ins;
                                distance_instruction = distance_instruction + turf.rhumbDistance(from1, to1);
                            }
                            else if (Math.abs(turf.bearingToAngle(prev_bearing_ins) - turf.bearingToAngle(current_bearing_ins)) > 60) {
                                if ((i - 1) >= 0) {
                                    prev_bearing_ins = current_bearing_ins;
                                    var turn_side = (Routeslng[Routeslng.length - 1] - Routeslng[i - 1]) * (Routeslat[i] - Routeslat[i - 1]) - (Routeslat[Routeslat.length - 1] - Routeslat[i - 1]) * (Routeslng[i] - Routeslng[i - 1])
                                    if (turn_side > 0) {
                                        if (Math.ceil(distance_instruction * 1000) == 0) {
                                            //                                            if(language == "EN")
                                            //                                            {
                                            //                                            instruction_text = instruction_text + "Move forword 1 meter & turn Right";
                                            //                                            Route_ins.push("Walk forword 1 meter and turn Right");
                                            //                                            }else
                                            //                                            {
                                            //                                              instruction_text = instruction_text + "التوجه للأمام مسافة متر ثم الي اليمين";
                                            //                                              Route_ins.push("التوجه للأمام مسافة متر ثم الي اليمين");
                                            //                                            }
                                            //
                                            //                                            distance_instruction = 0;
                                            //                                            Route_ins_lgn.push(Routeslng[i]);
                                            //                                            Route_ins_lat.push(Routeslat[i]);
                                        }
                                        else {

                                            if (language == "EN") {
                                                instruction_text = instruction_text + " Move forword  " + Math.ceil(distance_instruction * 1000) + " meter & turn Right";
                                                Route_ins.push("Walk forword  " + Math.ceil(distance_instruction * 1000) + " meter and turn Right");
                                            } else {
                                                instruction_text = instruction_text + "التوجه للامام مسافة  " + Math.ceil(distance_instruction * 1000) + " ثم الي اليمين";
                                                Route_ins.push(" التوجه للامام مسافة " + Math.ceil(distance_instruction * 1000) + " متر ثم الي اليمين");
                                            }

                                            Route_ins_lgn.push(Routeslng[Routeslng.length - 1]);
                                            Route_ins_lat.push(Routeslat[Routeslat.length - 1]);
                                            distance_instruction = 0;
                                        }

                                    }
                                    else if (turn_side < 0) {
                                        if (Math.ceil(distance_instruction * 1000) == 0) {
                                            //                                            if(language == "EN"){
                                            //                                                instruction_text = instruction_text + " Move forword 1 meter & turn Left";
                                            //                                                Route_ins.push("Wall forword 1 meter and turn Left");
                                            //                                            }else{
                                            //                                            instruction_text = instruction_text + " التوجه للامام متر ثم الي اليسار";
                                            //                                            Route_ins.push(" التوجه للامام متر ثم الي اليسار");
                                            //                                            }
                                            //                                            Route_ins_lgn.push(Routeslng[i]);
                                            //                                            Route_ins_lat.push(Routeslat[i]);
                                            //                                            distance_instruction = 0;
                                        }
                                        else {
                                            if (language == "EN") {
                                                Route_ins.push("Walk forword  " + Math.ceil(distance_instruction * 1000) + " meter and turn Left");
                                            } else {
                                                Route_ins.push("التوجه للامام مسافة" + Math.ceil(distance_instruction * 1000) + " متر ثم الي اليسار");
                                            }
                                            Route_ins_lgn.push(Routeslng[Routeslng.length - 1]);
                                            Route_ins_lat.push(Routeslat[Routeslat.length - 1]);
                                            distance_instruction = 0;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

            }
            if (instruction_text.length <= 0) {
                if (language == "EN") {
                    instruction_text = instruction_text + " Walk forword  ";
                    Route_ins.push(" Walk forword  ");
                }
                else {
                    instruction_text = instruction_text + " التوجه للامام   ";
                    Route_ins.push(" التوجه للامام   ");
                }
                Route_ins_lgn.push(Routeslng[0]);
                Route_ins_lat.push(Routeslat[0]);
            }
            if (current_lvl == change_lvl) {
                if (Math.ceil(distance_instruction * 1000) > 5) {
                    if (language == "EN") {
                        Route_ins.push("walk forward " + Math.ceil(distance_instruction * 1000));
                    } else {
                        Route_ins.push("التوجه للامام" + Math.ceil(distance_instruction * 1000));
                    }
                    Route_ins_lgn.push(Routeslng[Routeslng.length - 1]);
                    Route_ins_lat.push(Routeslat[Routeslng.length - 1]);
                    ins_lng = new Array();
                    ins_lat = new Array();
                } else {
                    if (language == "EN") {
                        Route_ins.push("You're about to reach the destination");
                    } else {
                        Route_ins.push("أنت على وشك الوصول إلى الوجهة");
                    }
                    Route_ins_lgn.push(Routeslng[Routeslng.length - 1]);
                    Route_ins_lat.push(Routeslat[Routeslng.length - 1]);
                    ins_lng = new Array();
                    ins_lat = new Array();
                }
            } else {
                if (language == "EN") {
                    Route_ins.push("Use elevator to go to " + change_lvl + " Floor");
                } else {
                    Route_ins.push("استخدم المصعد للذهاب للطابق" + change_lvl);
                }
                Route_ins_lgn.push(Routeslng[Routeslng.length - 1]);
                Route_ins_lat.push(Routeslat[Routeslng.length - 1]);
                ins_lng = new Array();
                ins_lat = new Array();
            }

            //$("#current-step").html(instruction_text);
            //$(".instructions").show();

        }

        var route_array_3;

        function shortestPath_version3(graph, source, target) {

            if (source == target) {
                return;
            }
            var queue = [source],
                visited = {
                    source: true
                },
                predecessor = {},
                tail = 0;
            while (tail < queue.length) {
                var u = queue[tail++],
                    neighbors = graph.neighbors[u];
                for (var i = 0; i < neighbors.length; ++i) {
                    var v = neighbors[i];
                    if (visited[v]) {
                        continue;
                    }
                    visited[v] = true;
                    if (v === target) {
                        var path_2 = [v];
                        while (u !== source) {
                            path_2.push(u);
                            u = predecessor[u];
                        }
                        path_2.push(u);
                        path_2.reverse();
                        route_array_3 = path_2;
                        return;
                    }
                    predecessor[v] = u;
                    queue.push(v);
                }
            }
        }

        var route_array_2;

        function shortestPath_version2(graph, source, target) {
            if (source == target) {
                return;
            }
            var queue = [source],
                visited = {
                    source: true
                },
                predecessor = {},
                tail = 0;
            while (tail < queue.length) {
                var u = queue[tail++],
                    neighbors = graph.neighbors[u];
                for (var i = 0; i < neighbors.length; ++i) {
                    var v = neighbors[i];
                    if (visited[v]) {
                        continue;
                    }
                    visited[v] = true;
                    if (v === target) {
                        var path_2 = [v];
                        while (u !== source) {
                            path_2.push(u);
                            u = predecessor[u];
                        }
                        path_2.push(u);
                        path_2.reverse();
                        route_array_2 = path_2;
                        return;
                    }
                    predecessor[v] = u;
                    queue.push(v);
                }
            }
        }


        function bluedot_lnglat(lng, lat) {

            var destination_lng = lng;
            var destination_lat = lat;
            var x = {
                lng: destination_lng,
                lat: destination_lat
            };

            blueDot.setLngLat(x, {
                animate: true,
                duration: 3000
            });
        }

        var distances = new Map();
        var indexs_elevatros = [];
        var popup;
        var popup_global;
        var elevator_global_lng;
        var elevator_global_lat;
        var elevator_global_lvl;

        var elevator_global_destination_lng;
        var elevator_global_destination_lat;
        var elevator_global_destination_lvl;
        var route_between_floors_flag = false;


        function route_between_buildings(lng, lat, level, name, icon_url) {
            route_between_floors_flag = true;

            distances = new Map();
            indexs_elevatros = [];
            indexs_destination_elevatros = [];

            Full_path_route = {
                'type': 'FeatureCollection',
                'features': [{
                    'type': 'Feature',
                    'geometry': {
                        'type': 'LineString',
                        'coordinates': []
                    }
                }]
            };

            var to_lng = lng;
            var to_lat = lat;
            var to_lvl = level;

            var from_lng = blueDot.getLngLat().lng;
            var from_lat = blueDot.getLngLat().lat;
            var from_lvl = current_lvl;

            bluedot_outside = false;

            // --------------------- Nerest Elevator from BlueDot ---------------------
            var key_first_elevator;
            var distance_elevator;
            var index_nearest_elevator;
            var counter_n = 0;

            for (var counter_elevators = 0; counter_elevators < elevators.length; counter_elevators++) {
                if (from_lvl == elevators[counter_elevators].zlevel) {
                    if (check_inside_building(elevators[counter_elevators].lng, elevators[counter_elevators].lat, to_lvl, from_lng, from_lat, from_lvl)) {
                        var lat1 = parseFloat(from_lat);
                        var lng1 = parseFloat(from_lng);
                        var lat2 = parseFloat(elevators[counter_elevators].lat);
                        var lng2 = parseFloat(elevators[counter_elevators].lng);
                        distance_elevator = getDistanceFromLatLonInKm(lat1, lng1, lat2, lng2);
                        distances.set(counter_elevators, distance_elevator);
                    }
                    else {
                        continue;
                    }
                }
            }

            distances = new Map([...distances.entries()].sort((a, b) => a[1] - b[1]));

            for (var a = 0; a < distances.size; a++) {
                indexs_elevatros[a] = Array.from(distances.keys())[a];
            }

            var found = false;
            for (var a = 0; a < distances.size; a++) {
                for (var b = 0; b < elevators.length; b++) {
                    if (elevators[b].zlevel == change_lvl) {
                        var from_lg = parseFloat(elevators[indexs_elevatros[a]].lng);
                        var from_lt = parseFloat(elevators[indexs_elevatros[a]].lat);
                        var lat1 = parseFloat(elevators[b].lat);
                        var lng1 = parseFloat(elevators[b].lng);
                        var dies = getDistanceFromLatLonInKm(from_lt, from_lg, lat1, lng1);

                        if (dies < 5 && dies != 0) {
                            index_nearest_elevator = indexs_elevatros[a];
                            found = true;
                            break;
                        }
                    }
                    if (found == true) {
                        break;
                    }
                }
                if (found == true) {
                    break;
                }
            }


            key_first_elevator = elevators[index_nearest_elevator].key;
            elevator_global_lng = elevators[index_nearest_elevator].lng;
            elevator_global_lat = elevators[index_nearest_elevator].lat;
            elevator_global_lvl = elevators[index_nearest_elevator].zlevel;

            // -----------------------------------------------------------------



            // --------------------- Nerest Elevator from Destination ---------------------
            distances_destination = new Map();
            indexs_elevatros = [];
            var key_destination_elevator;
            var distance_destination_elevator;
            var index_destination_nearest_elevator;
            var counter_destination = 0;

            for (var counter_elevators = 0; counter_elevators < elevators.length; counter_elevators++) {
                if (to_lvl == elevators[counter_elevators].zlevel) {
                    var lat1 = parseFloat(to_lat);
                    var lng1 = parseFloat(to_lng);
                    var lat2 = parseFloat(elevators[counter_elevators].lat);
                    var lng2 = parseFloat(elevators[counter_elevators].lng);
                    distance_destination_elevator = getDistanceFromLatLonInKm(lat1, lng1, lat2, lng2);
                    distances_destination.set(counter_elevators, distance_destination_elevator);
                }
            }

            distances_destination = new Map([...distances_destination.entries()].sort((a, b) => a[1] - b[1]));

            for (var a = 0; a < distances_destination.size; a++) {
                indexs_destination_elevatros[a] = Array.from(distances_destination.keys())[a];
            }

            found = false;
            for (var a = 0; a < distances_destination.size; a++) {
                for (var b = 0; b < elevators.length; b++) {
                    if (elevators[b].zlevel == change_lvl) {
                        var from_lg = parseFloat(to_lng);
                        var from_lt = parseFloat(to_lat);
                        var lat1 = parseFloat(elevators[b].lat);
                        var lng1 = parseFloat(elevators[b].lng);
                        var dies = getDistanceFromLatLonInKm(from_lt, from_lg, lat1, lng1);

                        if (dies < 10 && dies != 0) {
                            index_destination_nearest_elevator = indexs_destination_elevatros[a];
                            found = true;
                            break;
                        }
                    }
                    if (found == true) {
                        break;
                    }
                }
                if (found == true) {
                    break;
                }
            }


            key_destination_elevator = elevators[index_destination_nearest_elevator].key;
            elevator_global_destination_lng = elevators[index_destination_nearest_elevator].lng;
            elevator_global_destination_lat = elevators[index_destination_nearest_elevator].lat;
            elevator_global_destination_lvl = elevators[index_destination_nearest_elevator].zlevel;


            var popup1 = new mapboxgl.Popup({ closeOnClick: false })
                .setLngLat([parseFloat(elevators[index_nearest_elevator].lng), parseFloat(elevators[index_nearest_elevator].lat)])
                .setHTML('<p style ="font-style: italic;font-family: monospace; color:white; font-size: 11px ; margin: auto;"><i class="fa-solid fa-elevator"></i> BlueDot  <i class="fa-solid fa-circle-up"></i></p>')
                .addTo(map);

            var popup2 = new mapboxgl.Popup({ closeOnClick: false })
                .setLngLat([parseFloat(elevators[index_destination_nearest_elevator].lng), parseFloat(elevators[index_destination_nearest_elevator].lat)])
                .setHTML('<p style ="font-style: italic;font-family: monospace; color:white; font-size: 11px ; margin: auto;"><i class="fa-solid fa-elevator"></i> Elevator  <i class="fa-solid fa-circle-up"></i></p>')
                .addTo(map);

            // -----------------------------------------------------------------


            // var goto;

            // if (elevator_global_lvl == Level_route_poi) {

            //     if (to_lvl == 0) {
            //         goto = "G";
            //     } else {
            //         goto = to_lvl;
            //     }

            //     if (to_lvl > current_lvl) {
            //         popup = new mapboxgl.Popup({ closeOnClick: false })
            //             .setLngLat([parseFloat(elevators[index_nearest_elevator].lng), parseFloat(elevators[index_nearest_elevator].lat)])
            //             .setHTML('<p style ="font-style: italic;font-family: monospace; color:white; font-size: 11px ; margin: auto;"><i class="fa-solid fa-elevator"></i> Go to floor ' + goto + ' <i class="fa-solid fa-circle-up"></i></p>')
            //             .addTo(map);
            //     } else {
            //         popup = new mapboxgl.Popup({ closeOnClick: false })
            //             .setLngLat([parseFloat(elevators[index_nearest_elevator].lng), parseFloat(elevators[index_nearest_elevator].lat)])
            //             .setHTML('<p style ="font-style: italic;font-family: monospace; color:white; font-size: 11px ; margin: auto;"><i class="fa-solid fa-elevator"></i> Go to floor ' + goto + ' <i class="fa-solid fa-circle-down"></i></p>')
            //             .addTo(map);
            //     }
            // }

            // var key_second_elevator;
            // var distance_second_elevator;
            // var index_second_nearest_elevator;
            // var counter_2 = 0;

            // for (var counter_elevators_2 = 0; counter_elevators_2 < elevators.length; counter_elevators_2++) {
            //     if (0 == elevators[counter_elevators_2].zlevel) {
            //         if (counter_2 == 0) {
            //             counter_2++;
            //             var lat1 = parseFloat(elevators[index_nearest_elevator].lat);
            //             var lng1 = parseFloat(elevators[index_nearest_elevator].lng);
            //             var lat2 = parseFloat(elevators[counter_elevators_2].lat);
            //             var lng2 = parseFloat(elevators[counter_elevators_2].lng);
            //             distance_second_elevator = getDistanceFromLatLonInKm(lat1, lng1, lat2, lng2);
            //             index_second_nearest_elevator = counter_elevators_2;

            //         } else {
            //             var lat1 = parseFloat(elevators[index_nearest_elevator].lat);
            //             var lng1 = parseFloat(elevators[index_nearest_elevator].lng);
            //             var lat2 = parseFloat(elevators[counter_elevators_2].lat);
            //             var lng2 = parseFloat(elevators[counter_elevators_2].lng);
            //             var dis = getDistanceFromLatLonInKm(lat1, lng1, lat2, lng2);

            //             if (distance_second_elevator > dis) {
            //                 distance_second_elevator = dis;
            //                 index_second_nearest_elevator = counter_elevators_2;
            //             }
            //         }

            //     }
            // }

            // key_second_elevator = elevators[index_second_nearest_elevator].key;


            // //Minimum Distance Flag
            // var min_flag = 0;
            // var minumum_from;
            // var minumum_to;

            // //key for Start & end location
            // var start_key;
            // var end_key;

            // for (var key in Routes_array) {
            //     // Get
            //     var value = Routes_array[key];
            //     var spiltter = value.split(',');
            //     var check_near_lgn = spiltter[0];
            //     var check_near_lat = spiltter[1];
            //     var level = spiltter[2];

            //     // Comapre to find nearest waypoint to "From" & "To" location.
            //     var min_distance_from = getDistanceFromLatLonInKm(check_near_lat, check_near_lgn, from_lat, from_lng);
            //     var min_distance_to = getDistanceFromLatLonInKm(check_near_lat, check_near_lgn, to_lat, to_lng);

            //     //first time assign the distance as a miniumm distance
            //     if (min_flag == 0) {
            //         min_flag = 1;
            //         minumum_from = min_distance_from;
            //         minumum_to = min_distance_to;
            //         start_key = key;
            //         end_key = key;
            //     } else {
            //         //compare to get minimum distance
            //         if (level == from_lvl) {
            //             if (minumum_from > min_distance_from) {
            //                 minumum_from = min_distance_from;
            //                 start_key = key;
            //             }
            //         }
            //         if (level == to_lvl) {
            //             if (minumum_to > min_distance_to) {
            //                 minumum_to = min_distance_to;
            //                 end_key = key;

            //             }
            //         }
            //     }

            // }


            // console.log("Start Key Elevator : " + key_first_elevator);
            // console.log("End   Key Elevator : " + key_second_elevator);

            // shortestPath_version2(graph, start_key, key_first_elevator);
            // shortestPath_version3(graph, key_second_elevator, end_key);

            // for (var z = 0; z < route_array_2.length; z++) {
            //     route_array.push(route_array_2[z])
            // }

            // for (var z = 0; z < route_array_3.length; z++) {
            //     route_array.push(route_array_3[z])
            // }

            // var geojson = {
            //     'type': 'FeatureCollection',
            //     'features': [{
            //         'type': 'Feature',
            //         'geometry': {
            //             'type': 'LineString',
            //             'coordinates': []
            //         }
            //     }]
            // };

            // geojson.features[0].geometry.coordinates.push([blueDot.getLngLat().lng, blueDot.getLngLat().lat]);


            // var full_distance = 0;
            // var prefpointlng;
            // var prevpointlat;
            // for (var o = 0; o < route_array.length; o++) {
            //     var waypoint = Routes_array[route_array[o]];
            //     var array_coordinates = waypoint.split(',');
            //     var lgn = array_coordinates[0];
            //     var lat = array_coordinates[1];
            //     var level = array_coordinates[2];

            //     if (o == 0) {
            //         // FlyTo_animation(lgn, lat);
            //         init_route_lat = lat;
            //         init_route_lng = lgn;
            //         if (!bluedot_outside) {
            //             full_distance = full_distance + getDistanceFromLatLonInKm(blueDot.getLngLat().lat, blueDot.getLngLat().lng, lat, lgn);
            //         } else {
            //             full_distance = full_distance + getDistanceFromLatLonInKm(from_lat, from_lng, lat, lgn);
            //         } prefpointlng = lgn;
            //         prevpointlat = lat;
            //     } else if (o == 2) {
            //         if (!bluedot_outside) {
            //             full_distance = full_distance + getDistanceFromLatLonInKm(blueDot.getLngLat().lat, blueDot.getLngLat().lng, lat, lgn);
            //         } else {
            //             full_distance = full_distance + getDistanceFromLatLonInKm(from_lat, from_lng, lat, lgn);
            //         } second_route_lng = lgn;
            //         second_route_lat = lat;
            //         prefpointlng = lgn;
            //         prevpointlat = lat;
            //     } else {
            //         full_distance = full_distance + getDistanceFromLatLonInKm(prevpointlat, prefpointlng, lat, lgn);
            //         prefpointlng = lgn;
            //         prevpointlat = lat;
            //     }
            //     Full_path_route.features[0].geometry.coordinates.push([lgn, lat]);

            //     if (level == Level_route_poi) {
            //         geojson.features[0].geometry.coordinates.push([lgn, lat]);
            //     }
            // }
            // full_distance_to_destination = full_distance;

            // var time = Math.floor(full_distance) / 74;
            // full_time_to_destination = time;
            // // console.log("1 - Distance : " + full_distance);
            // // console.log("2 - Time     : " + time);
            // global_name = name;
            // global_distance = Math.floor(full_distance);
            // global_time = time;
            // global_zlevel = to_lvl;
            // global_icon = icon_url;
            // //journy_info(name, Math.floor(full_distance), time, to_lvl, icon_url);

            // // map.addSource('route', {
            // //     'type': 'geojson',
            // //     'data': geojson
            // // });

            // // map.addLayer({
            // //     'id': 'route',
            // //     'type': 'line',
            // //     'source': 'route',
            // //     'layout': {
            // //         'line-join': 'round',
            // //         'line-cap': 'round'
            // //     },
            // //     'paint': {
            // //         'line-color': '#02c4fa',
            // //         'line-width': 13
            // //     }
            // // });
            // if (!remove_extra_route_flag) {
            //     remove_route_layer();
            // }
            // Route_level();
        }


        function route_between_floors(lng, lat, level, name, icon_url) {
            route_between_floors_flag = true;
            distances = new Map();
            indexs_elevatros = [];

            Full_path_route = {
                'type': 'FeatureCollection',
                'features': [{
                    'type': 'Feature',
                    'geometry': {
                        'type': 'LineString',
                        'coordinates': []
                    }
                }]
            };

            var to_lng = lng;
            var to_lat = lat;
            var to_lvl = level;


            var points = turf.points([
                [blueDot.getLngLat().lng, blueDot.getLngLat().lat]
            ]);
            var ptsWithin = turf.pointsWithinPolygon(points, searchWithin);
            if (ptsWithin.features.length > 0) {
                var from_lng = blueDot.getLngLat().lng;
                var from_lat = blueDot.getLngLat().lat;
                var from_lvl = current_lvl;
                bluedot_outside = false;
            }
            else {
                if (getDistanceFromLatLonInKm(blueDot.getLngLat().lat, blueDot.getLngLat().lng, gate_lat, gate_lng) < getDistanceFromLatLonInKm(blueDot.getLngLat().lat, blueDot.getLngLat().lng, gate_lat_1, gate_lng_1)) {
                    var from_lng = gate_lng;
                    var from_lat = gate_lat;
                    var from_lvl = 0;
                } else {
                    var from_lng = gate_lng_1;
                    var from_lat = gate_lat_1;
                    var from_lvl = 0;
                }
                bluedot_outside = true;
            }
            var key_first_elevator;
            var distance_elevator;
            var index_nearest_elevator;
            var counter_n = 0;

            if (from_lvl == 0 && !check_elevators_inside_building(from_lng, from_lat, to_lng, to_lat)) {
                for (var counter_elevators = 0; counter_elevators < elevators.length; counter_elevators++) {
                    var lat1 = parseFloat(to_lat);
                    var lng1 = parseFloat(to_lng);

                    var lat2 = parseFloat(elevators[counter_elevators].lat);
                    var lng2 = parseFloat(elevators[counter_elevators].lng);

                    distance_elevator = getDistanceFromLatLonInKm(lat1, lng1, lat2, lng2);
                    distances.set(counter_elevators, distance_elevator);
                }
            }
            else {
                for (var counter_elevators = 0; counter_elevators < elevators.length; counter_elevators++) {
                    if (from_lvl == elevators[counter_elevators].zlevel && check_elevators_inside_building(from_lng, from_lat, elevators[counter_elevators].lng, elevators[counter_elevators].lat)) {

                        var lat1 = parseFloat(from_lat);
                        var lng1 = parseFloat(from_lng);

                        var lat2 = parseFloat(elevators[counter_elevators].lat);
                        var lng2 = parseFloat(elevators[counter_elevators].lng);

                        distance_elevator = getDistanceFromLatLonInKm(lat1, lng1, lat2, lng2);
                        distances.set(counter_elevators, distance_elevator);

                    }
                }
            }

            distances = new Map([...distances.entries()].sort((a, b) => a[1] - b[1]));

            for (var a = 0; a < distances.size; a++) {
                indexs_elevatros[a] = Array.from(distances.keys())[a];
            }

            var found = false;
            for (var a = 0; a < distances.size; a++) {
                for (var b = 0; b < elevators.length; b++) {
                    if (elevators[b].zlevel == change_lvl) {
                        var from_lg = parseFloat(elevators[indexs_elevatros[a]].lng);
                        var from_lt = parseFloat(elevators[indexs_elevatros[a]].lat);
                        var lat1 = parseFloat(elevators[b].lat);
                        var lng1 = parseFloat(elevators[b].lng);
                        var dies = getDistanceFromLatLonInKm(from_lt, from_lg, lat1, lng1);
                        if (dies < 5 && dies != 0) {
                            index_nearest_elevator = indexs_elevatros[a];
                            found = true;
                            break;
                        }
                    }
                    if (found == true) {
                        break;
                    }
                }
                if (found == true) {
                    break;
                }
            }


            key_first_elevator = elevators[index_nearest_elevator].key;
            elevator_global_lng = elevators[index_nearest_elevator].lng;
            elevator_global_lat = elevators[index_nearest_elevator].lat;
            elevator_global_lvl = elevators[index_nearest_elevator].zlevel;

            const marker1 = new mapboxgl.Marker()
                .setLngLat([elevator_global_lng, elevator_global_lat])
                .addTo(map);

            var goto;

            // if (elevator_global_lvl == Level_route_poi) {

            //     if (to_lvl == 0) {
            //         goto = "G";
            //     } else {
            //         goto = to_lvl;
            //     }

            //     if (to_lvl > current_lvl) {
            //         popup = new mapboxgl.Popup({ closeOnClick: false })
            //             .setLngLat([parseFloat(elevators[index_nearest_elevator].lng), parseFloat(elevators[index_nearest_elevator].lat)])
            //             .setHTML('<p style ="font-style: italic;font-family: monospace; color:white; font-size: 11px ; margin: auto;"><i class="fa-solid fa-elevator"></i> Go to floor ' + goto + ' <i class="fa-solid fa-circle-up"></i></p>')
            //             .addTo(map);
            //     } else {
            //         popup = new mapboxgl.Popup({ closeOnClick: false })
            //             .setLngLat([parseFloat(elevators[index_nearest_elevator].lng), parseFloat(elevators[index_nearest_elevator].lat)])
            //             .setHTML('<p style ="font-style: italic;font-family: monospace; color:white; font-size: 11px ; margin: auto;"><i class="fa-solid fa-elevator"></i> Go to floor ' + goto + ' <i class="fa-solid fa-circle-down"></i></p>')
            //             .addTo(map);
            //     }
            // }

            var key_second_elevator;
            var distance_second_elevator;
            var index_second_nearest_elevator;
            var counter_2 = 0;

            for (var counter_elevators_2 = 0; counter_elevators_2 < elevators.length; counter_elevators_2++) {

                if (to_lvl == elevators[counter_elevators_2].zlevel) {
                    if (counter_2 == 0) {
                        counter_2++;
                        var lat1 = parseFloat(elevators[index_nearest_elevator].lat);
                        var lng1 = parseFloat(elevators[index_nearest_elevator].lng);
                        var lat2 = parseFloat(elevators[counter_elevators_2].lat);
                        var lng2 = parseFloat(elevators[counter_elevators_2].lng);
                        distance_second_elevator = getDistanceFromLatLonInKm(lat1, lng1, lat2, lng2);
                        index_second_nearest_elevator = counter_elevators_2;

                    } else {
                        var lat1 = parseFloat(elevators[index_nearest_elevator].lat);
                        var lng1 = parseFloat(elevators[index_nearest_elevator].lng);
                        var lat2 = parseFloat(elevators[counter_elevators_2].lat);
                        var lng2 = parseFloat(elevators[counter_elevators_2].lng);
                        var dis = getDistanceFromLatLonInKm(lat1, lng1, lat2, lng2);


                        if (distance_second_elevator > dis) {
                            distance_second_elevator = dis;
                            index_second_nearest_elevator = counter_elevators_2;
                        }
                    }
                }
            }

            key_second_elevator = elevators[index_second_nearest_elevator].key;

            // var m = new mapboxgl.Marker({ color: 'black', rotation: 45 })
            // .setLngLat([key_second_elevator.lng, key_second_elevator.lat])
            // .addTo(map);

            //Minimum Distance Flag
            var min_flag = 0;
            var minumum_from;
            var minumum_to;

            //key for Start & end location
            var start_key;
            var end_key;

            for (var key in Routes_array) {
                // Get
                var value = Routes_array[key];
                var spiltter = value.split(',');
                var check_near_lgn = spiltter[0];
                var check_near_lat = spiltter[1];
                var level = spiltter[2];

                // Comapre to find nearest waypoint to "From" & "To" location.
                var min_distance_from = getDistanceFromLatLonInKm(check_near_lat, check_near_lgn, from_lat, from_lng);
                var min_distance_to = getDistanceFromLatLonInKm(check_near_lat, check_near_lgn, to_lat, to_lng);

                //first time assign the distance as a miniumm distance
                if (min_flag == 0) {
                    min_flag = 1;
                    minumum_from = min_distance_from;
                    minumum_to = min_distance_to;
                    start_key = key;
                    end_key = key;
                } else {
                    //compare to get minimum distance
                    if (level == from_lvl) {
                        if (minumum_from > min_distance_from) {
                            minumum_from = min_distance_from;
                            start_key = key;
                        }
                    }
                    if (level == to_lvl) {
                        if (minumum_to > min_distance_to) {
                            minumum_to = min_distance_to;
                            end_key = key;

                        }
                    }
                }
            }

            shortestPath_version2(graph, start_key, key_first_elevator);
            shortestPath_version3(graph, key_second_elevator, end_key);

            for (var z = 0; z < route_array_2.length; z++) {
                route_array.push(route_array_2[z])
            }

            for (var z = 0; z < route_array_3.length; z++) {
                route_array.push(route_array_3[z])
            }

            var geojson = {
                'type': 'FeatureCollection',
                'features': [{
                    'type': 'Feature',
                    'geometry': {
                        'type': 'LineString',
                        'coordinates': []
                    }
                }]
            };

            geojson.features[0].geometry.coordinates.push([blueDot.getLngLat().lng, blueDot.getLngLat().lat]);


            var full_distance = 0;
            var prefpointlng;
            var prevpointlat;
            for (var o = 0; o < route_array.length; o++) {
                var waypoint = Routes_array[route_array[o]];
                var array_coordinates = waypoint.split(',');
                var lgn = array_coordinates[0];
                var lat = array_coordinates[1];
                var level = array_coordinates[2];

                if (o == 0) {
                    // FlyTo_animation(lgn, lat);
                    init_route_lat = lat;
                    init_route_lng = lgn;
                    if (!bluedot_outside) {
                        full_distance = full_distance + getDistanceFromLatLonInKm(blueDot.getLngLat().lat, blueDot.getLngLat().lng, lat, lgn);
                    } else {
                        full_distance = full_distance + getDistanceFromLatLonInKm(from_lat, from_lng, lat, lgn);
                    } prefpointlng = lgn;
                    prevpointlat = lat;
                } else if (o == 2) {
                    if (!bluedot_outside) {
                        full_distance = full_distance + getDistanceFromLatLonInKm(blueDot.getLngLat().lat, blueDot.getLngLat().lng, lat, lgn);
                    } else {
                        full_distance = full_distance + getDistanceFromLatLonInKm(from_lat, from_lng, lat, lgn);
                    } second_route_lng = lgn;
                    second_route_lat = lat;
                    prefpointlng = lgn;
                    prevpointlat = lat;
                } else {
                    full_distance = full_distance + getDistanceFromLatLonInKm(prevpointlat, prefpointlng, lat, lgn);
                    prefpointlng = lgn;
                    prevpointlat = lat;
                }
                Full_path_route.features[0].geometry.coordinates.push([lgn, lat]);

                if (level == Level_route_poi) {
                    geojson.features[0].geometry.coordinates.push([lgn, lat]);
                }
            }
            full_distance_to_destination = full_distance;

            var time = Math.floor(full_distance) / 74;
            full_time_to_destination = time;
            // console.log("1 - Distance : " + full_distance);
            // console.log("2 - Time     : " + time);
            global_name = name;
            global_distance = Math.floor(full_distance);
            global_time = time;
            global_zlevel = to_lvl;
            global_icon = icon_url;
            //journy_info(name, Math.floor(full_distance), time, to_lvl, icon_url);

            // map.addSource('route', {
            //     'type': 'geojson',
            //     'data': geojson
            // });

            // map.addLayer({
            //     'id': 'route',
            //     'type': 'line',
            //     'source': 'route',
            //     'layout': {
            //         'line-join': 'round',
            //         'line-cap': 'round'
            //     },
            //     'paint': {
            //         'line-color': '#02c4fa',
            //         'line-width': 13
            //     }
            // });
            if (!remove_extra_route_flag) {
                remove_route_layer();
            }
            Route_level();
        }

        function remove_route_layer() {
            var mapLayer = map.getLayer('route');
            var mapSource = map.getSource('route');
            if (typeof mapSource !== 'undefined') {
                map.removeLayer("route");
                map.removeSource("route");
                map.removeLayer("route_outline");
                map.removeSource("route_outline");
            }

            var mapLayer = map.getLayer('route_outline');
            var mapSource = map.getSource('route_outline');
            if (typeof mapSource !== 'undefined') {
                map.removeLayer("route_outline");
                map.removeSource("route_outline");
            }


            var mapLayer = map.getLayer('route_another');
            var mapSource = map.getSource('route_another');
            if (typeof mapSource !== 'undefined') {
                map.removeLayer("route_another");
                map.removeSource("route_another");
            }

            var mapLayer = map.getLayer('route_another_outline');
            var mapSource = map.getSource('route_another_outline');
            if (typeof mapSource !== 'undefined') {
                map.removeLayer("route_another_outline");
                map.removeSource("route_another_outline");
            }
        }



        function firsttimefloor(bol) {
            first_f = bol;
        }

        function set_postion(lng_, lat_, zlevel) {

            if (first_move) {
                first_move = false;
                if (level_array[zlevel] == current_lvl) {
                    first_f = false;
                } else {
                    first_f = true;
                }
                map.flyTo({
                    center: [lng_, lat_],
                    essential: true,
                    zoom: 18.9,

                });
                var x = {
                    lng: lng_,
                    lat: lat_
                };
                blueDot.setLngLat(x);
            }
            else {

                current_lvl = level_array[zlevel];

                if (first_ff) {
                    first_ff = false;
                    current_lvl = level_array[zlevel];
                }
                zlevel = level_array[zlevel];

                if (zlevel != prefloor) {
                    first_f = false;
                    prefloor = zlevel;
                    var menubtn = document.getElementById("menu");
                    for (var i = 0; i < menubtn.childElementCount; i++) {
                        var floor = menubtn.children[i].innerText;
                        if (floor == "G") {
                            floor = 0;
                        } else {
                            floor = parseInt(floor);
                        }

                        if (floor == zlevel) {
                            if (zlevel == Level_route_poi) {
                                map.flyTo({
                                    center: [blueDot.getLngLat().lng, blueDot.getLngLat().lat],
                                    zoom: 19.489296826958224,
                                });
                            } else {
                                current_lvl = zlevel
                                menubtn.children[i].click();
                                get_instructions_flag = true;
                                if (routeEnabled) {
                                    remove_extra_route();
                                }
                                switch_to_current_floor()
                            }
                        }
                    }
                }

                if (routeEnabled) { // If there is Route.

                    if (Level_route_poi == current_lvl) {
                        //
                        if (getDistanceFromLatLonInKm(blueDot.getLngLat().lat, blueDot.getLngLat().lng, lat_, lng_) < 15) {


                            var line = turf.lineString(SmartRoute.features[0].geometry.coordinates);
                            var pt = turf.point([lng_, lat_]);
                            var snapped = turf.nearestPointOnLine(line, pt, { units: 'miles' });
                            var x = {
                                lng: snapped.geometry.coordinates[0],
                                lat: snapped.geometry.coordinates[1]
                            };
                            blue_lat = snapped.geometry.coordinates[1];
                            blue_lng = snapped.geometry.coordinates[0];

                            // var d = getDistanceFromLatLonInKm(blueDot.getLngLat().lat, blueDot.getLngLat().lng, lat_, lng_);
                            // console.log("Distance : "+d);
                            // var time_duration = d / 0.5;
                            // console.log("Time : "+(time_duration * 1000)+" Seconds");



                            map.flyTo({
                                center: [blue_lng, blue_lat],
                                essential: true,
                                zoom: 21.41617676156394,
                                pitch: 58.5,
                                speed: 0.5
                            });

                            var zx = {
                                lng: blue_lng,
                                lat: blue_lat
                            };

                            blueDot.setLngLat(zx);




                        }
                        else {
                            blue_lat = lat_;
                            blue_lng = lng_;

                            map.flyTo({
                                center: [blue_lng, blue_lat],
                                essential: true,
                                zoom: 21.41617676156394,
                                pitch: 58.5,
                                speed: 0.5
                            });

                            var newLngLat = {
                                lng: blue_lng,
                                lat: blue_lat
                            };

                            blueDot.setLngLat(newLngLat);
                            get_instructions_flag = true;

                        }
                        // Remove Extra Route.
                        if (getDistanceFromLatLonInKm(blue_lat, blue_lng, init_route_lat, init_route_lng) > 2) {
                            if (routeEnabled) {
                                remove_extra_route();
                            }
                        }
                        // Rotate Bearing to Route.
                        var point1 = turf.point([parseFloat(init_route_lng), parseFloat(init_route_lat)]);
                        var point2 = turf.point([parseFloat(second_route_lng), parseFloat(second_route_lat)]);
                        var bearing = turf.bearing(point1, point2);
                        var checkdire = matchedLocationOrinetation(map.getBearing(), turf.bearingToAngle(bearing), directions);

                        if (checkdire && bearing != 0) {

                            map.setBearing(bearing);
                            Rotate_Bearing(directions);
                        }

                    }

                    // Mohuto // cappatchinno // Amricano // Espresso // Mocha //



                    // if (previns == undefined || previns == "") {
                    //     $("#current-step").html(Route_ins[0]);
                    //     $(".instructions").show();
                    //     responsiveVoice.speak(Route_ins[0], "UK English Female", { pitch: 1.1 });
                    //     previns = Route_ins[0];
                    //     prev_route_ins[0] = Route_ins[0];
                    // }
                    // else {
                    //     for (var i = 0; i < Route_ins_lgn.length; i++) {
                    //         if (getDistanceFromLatLonInKm(blueDot.getLngLat().lat, blueDot.getLngLat().lng, parseFloat(Route_ins_lat[i]), parseFloat(Route_ins_lgn[i])) < 1) {
                    //             if (previns != Route_ins[i]) {
                    //                 for (var z = 0; z < prev_route_ins.length; z++) {
                    //                     if (Route_ins[i] == prev_route_ins[z]) {
                    //                         found++;
                    //                     }
                    //                 }
                    //                 if (found == 0) {
                    //                     $("#current-step").html(Route_ins[i]);
                    //                     $(".instructions").show();
                    //                     previns = Route_ins[i];
                    //                     responsiveVoice.speak(Route_ins[i], "UK English Female", { pitch: 1.1 });
                    //                     prev_route_ins[i] = Route_ins[i];
                    //                 }
                    //             }
                    //         }
                    //     }

                    // }

                    if (full_distance_to_destination < 5 && routeEnabled) {
                        routeEnabled = false;
                        ClearRoute();
                        route_array = [];
                        modal.style.display = "none";
                        var reached_str;
                        if (language == "AR") {
                            reached_str = "Reached to destination";
                            // responsiveVoice.speak(reached_str, "UK English Female", { pitch: 1 });
                        }
                        else {
                            reached_str = "Reached to destination";
                            // responsiveVoice.speak(reached_str, "UK English Female", { pitch: 1 });
                        }

                        var popup = new mapboxgl.Popup()
                            .setLngLat([blueDot.getLngLat().lng, blueDot.getLngLat().lat])
                            .setHTML("<p style='color: white;font-size: 18px;margin-top: 10%;'>" + reached_str + "<p>")
                            .setMaxWidth("300px")
                            .addTo(map);
                        setTimeout(() => {
                            popup.remove()
                        }, 5000);
                    }
                }
                else // When There is No Route.
                {
                    var newLngLat = {
                        lng: lng_,
                        lat: lat_
                    };
                    blueDot.setLngLat(newLngLat);
                }
            }
        }

        function set_postion_backup(lng_, lat_, zlevel) {

            // console.log("1 - lng : " + lng_);
            // console.log("2 - lat : " + lat_);
            // console.log("3 -  zlevel " + zlevel);

            if (first_move) {

                if (level_array[zlevel] == current_lvl) {
                    first_f = false;
                } else {
                    first_f = true;
                }
                map.flyTo({
                    center: [lng_, lat_],
                    essential: true,
                    zoom: 19.489296826958224,
                });
                first_move = false;
                setTimeout(function run() {
                    map.flyTo({
                        center: [lng_, lat_],
                        essential: true,
                        zoom: 19.489296826958224,
                    });
                }, 4000);

                //bluedot_lnglat(parseFloat(lng_), parseFloat(lat_));

            } else {

                speed = 15;
                destination_lng = lng_;
                destination_lat = lat_;

                current_lvl = level_array[zlevel];
                // if (current_lvl != level_array[zlevel]) {
                //     for (var i = 0; i < elevators.length; i++) {
                //         if (getDistanceFromLatLonInKm(parseFloat(elevators[i].lat), parseFloat(elevators[i].lng), blueDot.getLngLat().lat, blueDot.getLngLat().lng) < 1000) {
                //             current_lvl = level_array[zlevel];
                //         }
                //     }
                // }

                if (first_ff) {
                    first_ff = false;
                    current_lvl = level_array[zlevel];
                }

                zlevel = level_array[zlevel];

                if (zlevel != prefloor || first_f) {

                    var nearelevators = false;

                    for (var i = 0; i < elevators.length; i++) {
                        if (getDistanceFromLatLonInKm(parseFloat(elevators[i].lat), parseFloat(elevators[i].lng), blueDot.getLngLat().lat, blueDot.getLngLat().lng) < 4) {
                            nearelevators = true;
                            //console.log("Elevator : " + nearelevators);
                            beacon_floor_index = zlevel;
                            //window.interface.update_Beacons(beacon_floor_index);
                        }

                    }

                    nearelevators = true;

                    if (nearelevators || first_f) {
                        first_f = false;
                        prefloor = zlevel;
                        var menubtn = document.getElementById("menu");
                        for (var i = 0; i < menubtn.childElementCount; i++) {
                            var floor = menubtn.children[i].innerText;
                            if (floor == "G") {
                                floor = 0;
                            } else {
                                floor = parseInt(floor);
                            }

                            if (floor == zlevel) {
                                if (zlevel == Level_route_poi) {
                                    map.flyTo({
                                        center: [blueDot.getLngLat().lng, blueDot.getLngLat().lat],
                                        zoom: 19.489296826958224,
                                    });
                                } else {
                                    current_lvl = zlevel
                                    menubtn.children[i].click();
                                    Route_ins = new Array();
                                    prev_route_ins = new Array();
                                    Route_ins_lgn = new Array();
                                    Route_ins_lat = new Array();
                                    previns = "";
                                }
                            }
                        }
                    }
                }

                if (Level_route_poi == current_lvl) {

                    var x;

                    if (routeEnabled) {

                        if (Route_by_level.features[0].geometry.coordinates.length > 0) {
                            var line = turf.lineString(Route_by_level.features[0].geometry.coordinates);
                            var pt = turf.point([destination_lng, destination_lat]);
                            var snapped = turf.nearestPointOnLine(line, pt, {
                                units: 'miles'
                            });

                            x = {
                                lng: snapped.geometry.coordinates[0],
                                lat: snapped.geometry.coordinates[1]
                            };

                            blue_lat = snapped.geometry.coordinates[1];
                            blue_lng = snapped.geometry.coordinates[0];
                        } else {
                            x = {
                                lng: destination_lng,
                                lat: destination_lat
                            };
                        }
                        var point1 = turf.point([parseFloat(init_route_lng), parseFloat(init_route_lat)]);
                        var point2 = turf.point([parseFloat(second_route_lng), parseFloat(second_route_lat)]);
                        var bearing = turf.bearing(point1, point2);
                        var checkdire = matchedLocationOrinetation(map.getBearing(), turf.bearingToAngle(bearing), directions);

                        if (checkdire && bearing != 0) {
                            map.setBearing(bearing);
                            Rotate_Bearing(directions);
                        } else {
                            var newLngLat = {
                                lng: destination_lng,
                                lat: destination_lat
                            };
                        }


                        setTimeout(function () {
                            if (getDistanceFromLatLonInKm(blue_lat, blue_lng, init_route_lat, init_route_lng) >= 0) {
                                if (routeEnabled) {
                                    remove_extra_route();
                                }
                            }
                        }, 3200);


                    }

                    if (getDistanceFromLatLonInKm(blueDot.getLngLat().lat, blueDot.getLngLat().lng, destination_lat, destination_lng) > 10) {
                        x = {
                            lng: destination_lng,
                            lat: destination_lat
                        };
                        blue_lat = destination_lat;
                        blue_lng = destination_lng;
                        Route_ins = new Array();
                        prev_route_ins = new Array();
                        Route_ins_lgn = new Array();
                        Route_ins_lat = new Array();
                        previns = "";
                    }
                    else {
                        x = {
                            lng: destination_lng,
                            lat: destination_lat
                        };
                    }

                    blueDot.setLngLat(x, {
                        animate: true,
                        duration: 3000
                    });



                    if (full_distance_to_destination < 5 && routeEnabled) {
                        routeEnabled = false;
                        ClearRoute();
                        route_array = [];
                        modal.style.display = "none";
                        var reached_str;
                        if (language == "AR") {
                            reached_str = "Reached to destination";
                            // responsiveVoice.speak(reached_str, "UK English Female", { pitch: 1 });
                        }
                        else {
                            reached_str = "Reached to destination";
                            // responsiveVoice.speak(reached_str, "UK English Female", { pitch: 1 });
                        }

                        var popup = new mapboxgl.Popup()
                            .setLngLat([blueDot.getLngLat().lng, blueDot.getLngLat().lat])
                            .setHTML("<p style='color: white;font-size: 18px;margin-top: 10%;'>" + reached_str + "<p>")
                            .setMaxWidth("300px")
                            .addTo(map);
                        setTimeout(() => {
                            popup.remove()
                        }, 5000);
                    }

                }

                if (routeEnabled) {

                    if (previns == undefined || previns == "") {
                        $("#current-step").html(Route_ins[0]);
                        $(".instructions").show();
                        // responsiveVoice.speak(Route_ins[0], "UK English Female", { pitch: 1.1 });
                        previns = Route_ins[0];
                        prev_route_ins[0] = Route_ins[0];
                    }
                    else {
                        for (var i = 0; i < Route_ins_lgn.length; i++) {
                            if (getDistanceFromLatLonInKm(destination_lat, destination_lng, Route_ins_lat[i], Route_ins_lgn[i]) < 1) {
                                if (previns != Route_ins[i]) {
                                    for (var z = 0; z < prev_route_ins.length; z++) {
                                        if (Route_ins[i] == prev_route_ins[z]) {
                                            found++;
                                        }
                                    }
                                    if (found == 0) {
                                        $("#current-step").html(Route_ins[i]);
                                        $(".instructions").show();
                                        previns = Route_ins[i];
                                        // responsiveVoice.speak(Route_ins[i], "UK English Female", { pitch: 1.1 });
                                        prev_route_ins[i] = Route_ins[i];
                                    }
                                }
                            }
                        }

                    }

                } else {
                    var newLngLat = {
                        lng: destination_lng,
                        lat: destination_lat
                    };
                    blueDot.setLngLat(newLngLat, {
                        animate: true,
                        duration: 3000
                    });
                }
            }

        }

        //Rotate the icon
        function Rotate_Bearing(b) {
            directions = b;
            var maprotation = map.getBearing();
            var oriantedDirection = turf.bearingToAzimuth(b - maprotation);
            ze = oriantedDirection;
            pointx.features[0].properties.heading = oriantedDirection;
            map.getSource('pointx').setData(pointx);
        }

        // setCurrentLocation to set bearing shadow with the ;

        function SetCurrentLocation() {

            pointx.features[0].geometry.coordinates = [blueDot.getLngLat().lng, blueDot.getLngLat().lat];
            map.getSource('pointx').setData(pointx);
            ReSetCurrentLocation();

        }

        function ReSetCurrentLocation() {

            setTimeout(function () {
                SetCurrentLocation();
            }, 100);
        }
        function matchedLocationOrinetation(mapOriantation, routeBearing, direction) {
            var maxangle = (routeBearing + 35);
            var minangle = (routeBearing - 35);



            if (0 < maxangle && 0 < minangle || mapOriantation != routeBearing) {
                if (inRange(direction, minangle, maxangle)) {
                    return true;
                }
            }
            return false;
        }

        function inRange(val, start, end) {
            if (val >= Math.min(start, end) && val <= Math.max(start, end)) {
                return true;
            } else {
                return false;
            }
        }

        function Toast_message_parking(text, actionText = null, actionCallback = null) {

            const toastStyle = {
                background: "#0090ba", // Solid background color
                color: "#ffffff", // Text color
                padding: "27px", // Padding for better spacing
                borderRadius: "8px", // Rounded corners
                boxShadow: "0 2px 10px rgba(0, 0, 0, 0.3)", // Shadow for depth
                fontSize: "16px", // Font size
                fontFamily: "Arial, sans-serif", // Font family
                textAlign: "center", // Centered text
                display: "flex", // Flexbox for alignment
                alignItems: "center", // Center items vertically
                justifyContent: "space-between" // Space between text and button
            };

            const toastContent = document.createElement("div");
            toastContent.innerHTML = `
                <div style="flex-grow: 1;">
                    <i class="fas fa-car" style="margin-right: 10px;"></i>
                    ${text}
                </div>
            `;

            if (actionText && actionCallback) {
                const actionButton = document.createElement("button");
                actionButton.innerText = actionText;
                actionButton.style.background = "transparent";
                actionButton.style.color = "#ffffff";
                actionButton.style.border = "none";
                actionButton.style.cursor = "pointer";
                actionButton.style.marginLeft = "10px";
                actionButton.onclick = function () {
                    actionCallback();
                    Toastify().hideToast(); // Hide the toast after action
                };

                toastContent.appendChild(actionButton);
            }

            Toastify({
                node: toastContent,
                duration: 50000000, // Duration of the toast
                gravity: "top", // `top` or `bottom`
                position: "center", // `left`, `center` or `right`
                stopOnFocus: true, // Prevents dismissing of toast on hover
                style: toastStyle,
                onClick: function () { } // Callback after click
            }).showToast();
        }

        var full_distance = 0;

        function remove_extra_route() {

            route_array = [];
            var slct_lng = change_lg;
            var slct_lat = change_lt;
            var slct_lvl = change_lvl;
            var dest_name = change_name;
            var icon = change_icon;

            var selected_poi = {
                'type': 'FeatureCollection',
                'features': [{
                    'type': 'Feature',
                    'geometry': {
                        'type': 'LineString',
                        'coordinates': []
                    }
                }]
            };
            remove_extra_route_flag = true;
            // console.log("1 - lg : " + change_lg);
            // console.log("2 - lt : " + change_lt);
            // console.log("3 - lvl : " + change_lvl);
            // console.log("4 - name : " + change_name);
            // console.log("5 - icon : " + change_icon);

            draw_path_to_poi(dest_name, slct_lng, slct_lat, slct_lvl, icon, selected_poi);

        }


        function sortChildrenDivsById(parentId) {
            var parent = document.getElementById(parentId);
            var children = parent.getElementsByTagName("a");
            var ids = [], i, len;
            for (i = 0, len = children.length; i < len; i++) {
                ids.push(parseInt(children[i].id.replace(/^.*_/g, ""), 10));
            }
            ids.sort(function (a, b) { return (a - b); });
            for (i = 0, len = ids.length; i < len; i++) {
                parent.appendChild(document.getElementById("dv_" + ids[i]));
            }
        }


        var Tour = (function () {
            var t = [],
                o, cur
            T = {
                step: {
                    pl: "krok",
                    en: "step",
                    be: "крок",
                    ca: "pas",
                    cs: "krok",
                    da: "trin",
                    de: "Schritt",
                    el: "βήμα",
                    es: "paso",
                    et: "samm",
                    fi: "vaihe",
                    fr: "étape",
                    hu: "lépés",
                    it: "passo",
                    lt: "žingsnis",
                    lv: "solis",
                    mk: "чекор",
                    nl: "stap",
                    no: "trinn",
                    pt: "passo",
                    ru: "шаг",
                    sk: "krok",
                    sl: "korak",
                    sq: "hapi",
                    sv: "steg",
                    tr: "adım",
                    uk: "крок",
                    ar: "خطوة"
                },
                Next: {
                    pl: "Następny",
                    en: "Next",
                    be: "Далей",
                    ca: "Següent",
                    cs: "Další",
                    da: "Næste",
                    de: "Weiter",
                    el: "Την επόμενη",
                    es: "Siguiente",
                    et: "Järgmine",
                    fi: "Seuraava",
                    fr: "Prochaine",
                    hu: "Következő",
                    it: "Accanto",
                    lt: "Kitas",
                    lv: "Nākamā",
                    mk: "Следна",
                    nl: "Volgende",
                    no: "Neste",
                    pt: "Próximo",
                    ru: "Далее",
                    sk: "Ďalej",
                    sl: "Naprej",
                    sq: "Tjetër",
                    sv: "Nästa",
                    tr: "Gelecek",
                    uk: "Далі",
                    ar: "التالي"
                },
                Previous: {
                    pl: "Poprzedni",
                    en: "Previous",
                    be: "Папярэдні",
                    ca: "Anteriors",
                    cs: "Předchozí",
                    da: "Tidligere",
                    de: "Vorherige",
                    el: "Προηγούμενο",
                    es: "Anterior",
                    et: "Eelmine",
                    fi: "Edellinen",
                    fr: "Précédente",
                    hu: "Előző",
                    it: "Precedente",
                    lt: "Ankstesnis",
                    lv: "Iepriekšējā",
                    mk: "Претходна",
                    nl: "Vorige",
                    no: "Tidligere",
                    pt: "Anterior",
                    ru: "Предыдущий",
                    sk: "Predchádzajúce",
                    sl: "Prejšnji",
                    sq: "E mëparshme",
                    sv: "Föregående",
                    tr: "Önceki",
                    uk: "Попередній",
                    ar: "السابق"
                },
                Finish: {
                    pl: "Zakończ",
                    // en: "إنهاء",
                    en: "Finish",
                    be: "Аздабленне",
                    ca: "Acabat",
                    cs: "Dokončit",
                    da: "Finish",
                    de: "Finish",
                    el: "Τελειώνει",
                    es: "Acabado",
                    et: "Lõpeta",
                    fi: "Loppuun",
                    fr: "Finition",
                    hu: "Befejezés",
                    it: "Finitura",
                    lt: "Apdaila",
                    lv: "Apdare",
                    mk: "Заврши",
                    nl: "Afwerking",
                    no: "Ferdig",
                    pt: "Acabamento",
                    ru: "Отделка",
                    sk: "Povrch",
                    sl: "Zaključek",
                    sq: "Finish",
                    sv: "Avsluta",
                    tr: "Bitir",
                    uk: "Оздоблення",
                    ar: "إنهاء"
                }
            };

            function _t(s) {
                return T[s][t[cur].language] || T[s]['ar'];
            }

            function step(n) {
                cur = n;
                $('.tourStep, .tourBg').remove();

                if (!t[n]) {
                    return;
                }

                if (language == "EN") {
                    $('body').append([
                        '<div style="    min-width: 250px;position: absolute;left: 20%;top: 15%;display: block;" class="tourStep popover" step="' + n + '">',
                        '<div class="arrow"></div>',
                        '<div class="panel-default">',
                        !t[n].close ? '' : '<button class="tourClose close pull-right">&times;&nbsp;</button>',
                        '<div class="panel-body">',
                        t[n].content,
                        '</div>',
                        '<div class="panel-footer">',
                        '<div class="pull-right">',
                        '<div class="tourPrev btn btn-default btn-sm" style:"background-color: #860E4E;border-color: #630637;">السابق</div> ',
                        '<div id="nextBtnAr" class="tourNext btn btn-primary btn-sm" style:"background-color: #860E4E;border-color: #630637;">التالي</div>',
                        '</div>',
                        '<h6>خطوة ' + (n + 1) + ' / ' + t.length + '</h6>',
                        '</div>',
                        '</div>',
                        '</div>'
                    ].join(''));
                }
                else {
                    $('body').append([
                        '<div style="    min-width: 250px;position: absolute;left: 20%;top: 15%;display: block;" class="tourStep popover" step="' + n + '">',
                        '<div class="arrow"></div>',
                        '<div class="panel-default">',
                        !t[n].close ? '' : '<button class="tourClose close pull-right">&times;&nbsp;</button>',
                        '<div class="panel-body">',
                        t[n].content,
                        '</div>',
                        '<div class="panel-footer">',
                        '<div class="pull-right">',
                        '<div class="tourPrev btn btn-default btn-sm">Previous</div> ',
                        '<div id="nextBtnEn" class="tourNext btn btn-primary btn-sm">Next</div>',
                        '</div>',
                        '<h6>Step ' + (n + 1) + ' / ' + t.length + '</h6>',
                        '</div>',
                        '</div>',
                        '</div>'
                    ].join(''));
                }

                var el = $('.tourStep')
                    .addClass(t[n].position)
                    .css({
                        minWidth: 250
                    }),
                    x = 0,
                    y = 0;

                if (t[n].element && !!t[n].element.length) {
                    var x1 = 1e6,
                        y1 = 1e6,
                        x2 = 0,
                        y2 = 0;

                    t[n].element.each(function (k, v) {
                        var ofs = $(v).offset();
                        x1 = Math.min(x1, ofs.left + t[n].forceCorrectionLeft);
                        y1 = Math.min(y1, ofs.top + t[n].forceCorrectionTop);

                        x2 = Math.max(x2, ofs.left + t[n].forceCorrectionLeft + t[n].forceCorrectionWidth
                            + parseInt($(v).css('border-left-width'))
                            + parseInt($(v).css('padding-left'))
                            + $(v).width()
                            + parseInt($(v).css('padding-right'))
                            + parseInt($(v).css('border-right-width'))
                        );

                        y2 = Math.max(y2, ofs.top + t[n].forceCorrectionTop + t[n].forceCorrectionHeight
                            + parseInt($(v).css('border-top-width'))
                            + parseInt($(v).css('padding-top'))
                            + $(v).height()
                            + parseInt($(v).css('padding-bottom'))
                            + parseInt($(v).css('border-bottom-width'))
                        );
                    });

                    switch (t[n].position) {
                        case 'top':
                            y = y1 - el.height();
                            x = ((x1 + x2) >> 1) - (el.width() >> 1);
                            break;

                        case 'right':
                            y = ((y1 + y2) >> 1) - (el.height() >> 1);
                            x = x2;
                            break;

                        case 'left':
                            y = ((y1 + y2) >> 1) - (el.height() >> 1);
                            x = x1 - el.width();
                            break;

                        case 'bottom':
                            y = y2;
                            x = ((x1 + x2) >> 1) - (el.width() >> 1);
                            break;
                    };
                };

                el
                    .css({
                        position: 'absolute',
                        left: x,
                        top: y
                    })
                    .show();

                if (t[n].spotlight) {
                    var p = t[n].padding;
                    $('body').append(Array(5).join('<div class="tourBg"></div>'));

                    var pos = [
                        {
                            bottom: 'auto',
                            height: y1 - p
                        },
                        {
                            top: y2 + p,
                            height: $(document).height() - y2 - p
                        },
                        {
                            right: 'auto',
                            bottom: 'auto',
                            top: y1 - p,
                            width: x1 - p,
                            height: 2 * p + y2 - y1
                        },
                        {
                            left: x2 + p,
                            bottom: 'auto',
                            top: y1 - p,
                            height: 2 * p + y2 - y1
                        }
                    ];

                    $('.tourBg')
                        .css({
                            position: 'absolute',
                            zIndex: 1000,
                            top: 0,
                            bottom: 0,
                            right: 0,
                            left: 0,
                            background: '#000',
                            opacity: 0.3
                        }).each(function (k, v) {
                            $(v).css(pos[k]);
                        });
                }

                if (!!t[n].scroll) {
                    var my = ((Math.min(y, y1) + Math.max(y + el.height(), y2)) >> 1) - ($(window).height() >> 1),
                        mx = ((Math.min(x, x1) + Math.max(x + el.width(), x2)) >> 1) - ($(window).width() >> 1);

                    $('html, body').animate({
                        scrollTop: Math.max(0, Math.min(y, y1, my)),
                        scrollLeft: Math.max(0, Math.min(x, x1, mx))
                    });
                }

                if (!n) {
                    $('.tourPrev').remove();
                }

                if (n > t.length - 2) {
                    $('.tourNext').text(_t('Finish'));
                }

                $('.tourStep')
                    .on('click', '.tourNext:not([disabled])', Tour.next)
                    .on('click', '.tourPrev:not([disabled])', Tour.prev)
                    .on('click', '.tourClose:not([disabled])', Tour.close);

                (t[n].onstep || Tour.onstep || function () { })(t[n]);
            }

            $(window).on('resize', function () {
                if (!!Tour.onresize) {
                    Tour.onresize();
                }
            });

            return {
                run: function (tour, options) {
                    try {
                        t = [];
                        cur = 0;
                        if (language == "EN") {
                            o = {
                                close: true,
                                content: '',
                                language: 'ar',
                                padding: 5,
                                position: 'right',
                                scroll: true,
                                spotlight: true,
                                forceCorrectionLeft: 0,
                                forceCorrectionTop: 0,
                                forceCorrectionWidth: 0,
                                forceCorrectionHeight: 0,
                                onstep: null,
                            };
                        }
                        else {
                            o = {
                                close: true,
                                content: '',
                                language: 'en',
                                padding: 5,
                                position: 'right',
                                scroll: true,
                                spotlight: true,
                                forceCorrectionLeft: 0,
                                forceCorrectionTop: 0,
                                forceCorrectionWidth: 0,
                                forceCorrectionHeight: 0,
                                onstep: null,
                            };
                        }

                        for (var k in options) {
                            o[k] = options[k];
                        }

                        $(tour).each(function (k, v) {
                            for (var kk in o) {
                                v[kk] = v[kk] || o[kk];
                            };

                            if (v.element && !!v.element.length) {
                                t.push(v);
                            }
                        });

                        step(cur);

                        if (!!Tour.onstart) {
                            Tour.onstart();
                        }
                    } catch (e) { }
                },

                next: function () {
                    step(cur + 1);

                    if (cur == t.length) {
                        if (!!Tour.onfinish) {
                            Tour.onfinish();
                        }
                    }
                },

                prev: function () {
                    step(cur - 1);
                },

                current: function () {
                    return cur;
                },

                close: function () {
                    step(-1);

                    if (!!Tour.onclose) {
                        Tour.onclose();
                    }
                },

                onstart: null,
                onfinish: null,
                onclose: null,
                onstep: null,

                onresize: function () {
                    var n = cur - 1;
                    step(-1);
                    cur = n;

                    setTimeout(function () {
                        Tour.next();
                    }, 20);
                }
            };
        })();

        function instructions() {
            if (language == "EN") {
                Tour.run([
                    {
                        element: $('.mapboxgl-ctrl-top-right'),
                        position: 'bottom',

                        content: 'يمكنك البحث عن وجهتك من هنا'
                    },
                    {
                        element: $('#language'),
                        position: 'right',
                        content: 'يمكنك تغيير لغة الخريطة من هنا'
                    },
                    {
                        element: $('#menu'),
                        position: 'right',
                        content: 'يمكنك استعراض جميع الادوار من هنا'
                    },
                    {
                        element: $('#currentlocation'),
                        position: 'left',
                        spotlight: true,
                        padding: 10,
                        content: 'البحث عن موقعك الحالي'
                    },
                    {
                        element: $('.mapboxgl-ctrl-bottom-right'),
                        position: 'left',
                        content: 'خاصية التكبير والتصغير وتوجيه الخريطة'
                    },
                    {
                        element: $('#change_dialog'),
                        position: 'bottom',
                        content: 'يمكنك اختيار الوجهة مباشرة من الخريطة بواسطة النقر عليها'
                    },
                ]);
            }
            else {
                Tour.run([
                    {
                        element: $('.mapboxgl-ctrl-top-right'),
                        position: 'bottom',

                        content: 'You can search for a destinations from here'
                    },
                    {
                        element: $('#language'),
                        position: 'right',

                        content: 'You can change the maps language from here'
                    },
                    {
                        element: $('#menu'),
                        position: 'right',
                        content: 'You can switch floors from here'
                    },
                    {
                        element: $('#currentlocation'),
                        position: 'left',
                        spotlight: true,
                        padding: 10,
                        content: 'Find your current location'
                    },
                    {
                        element: $('.mapboxgl-ctrl-bottom-right'),
                        position: 'left',
                        content: 'You can zoom in and out'
                    },
                    {
                        element: $('#change_dialog'),
                        position: 'bottom',
                        content: 'You can choose your destination directly from the map by clicking on it'
                    },


                ]);
            }

        }


        var fixed_layers = '[{"building_floor":{"id":7,"building_id":2,"name":"7","configured":true,"created_at":"2021-11-17T09:09:50.000+03:00","updated_at":"2021-11-17T09:09:50.000+03:00","coordinates":[],"layers":[{"id":37,"building_floor_id":7,"position":1,"kind":"outlayer","created_at":"2021-11-17T09:09:50.865+03:00","updated_at":"2021-11-17T09:09:50.872+03:00","file":{"id":42,"content_type":"application/octet-stream","filename":"Outline.geojson","url":"https://d1m6d407onyqpz.cloudfront.net/rails/active_storage/blobs/proxy/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBOZz09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--ccf0c8c6c6d502ddff94463b80395adb896291de/Outline.geojson","created_at":"2021-11-17T09:09:50.000+03:00"}}]}},{"building_floor":{"id":6,"building_id":2,"name":"6","configured":true,"created_at":"2021-11-17T09:09:17.000+03:00","updated_at":"2021-11-17T09:09:17.000+03:00","coordinates":[],"layers":[{"id":36,"building_floor_id":6,"position":1,"kind":"outlayer","created_at":"2021-11-17T09:09:17.375+03:00","updated_at":"2021-11-17T09:09:17.380+03:00","file":{"id":41,"content_type":"application/octet-stream","filename":"Outline.geojson","url":"https://d1m6d407onyqpz.cloudfront.net/rails/active_storage/blobs/proxy/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBOUT09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--05a92cb1f18fc9f81829eb7ba9cb5e3d36c8c4bc/Outline.geojson","created_at":"2021-11-17T09:09:17.000+03:00"}}]}},{"building_floor":{"id":5,"building_id":2,"name":"5","configured":true,"created_at":"2021-11-17T09:08:41.000+03:00","updated_at":"2021-11-17T09:08:41.000+03:00","coordinates":[],"layers":[{"id":35,"building_floor_id":5,"position":1,"kind":"outlayer","created_at":"2021-11-17T09:08:41.563+03:00","updated_at":"2021-11-17T09:08:41.569+03:00","file":{"id":40,"content_type":"application/octet-stream","filename":"Outline.geojson","url":"https://d1m6d407onyqpz.cloudfront.net/rails/active_storage/blobs/proxy/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBOQT09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--6ba9262e83b310032395c51ac7ac51a70683932a/Outline.geojson","created_at":"2021-11-17T09:08:41.000+03:00"}}]}},{"building_floor":{"id":4,"building_id":2,"name":"4","configured":true,"created_at":"2021-11-17T09:06:39.000+03:00","updated_at":"2021-11-17T09:08:11.000+03:00","coordinates":[],"layers":[{"id":33,"building_floor_id":4,"position":1,"kind":"outlayer","created_at":"2021-11-17T09:06:39.640+03:00","updated_at":"2021-11-17T09:06:39.646+03:00","file":{"id":38,"content_type":"application/octet-stream","filename":"Outline.geojson","url":"https://d1m6d407onyqpz.cloudfront.net/rails/active_storage/blobs/proxy/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBNUT09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--073ccd8cb504b63cfccd832f3edd1cc0ac7c3dd9/Outline.geojson","created_at":"2021-11-17T09:06:39.000+03:00"}}]}},{"building_floor":{"id":3,"building_id":2,"name":"1","configured":true,"created_at":"2021-11-17T09:03:50.000+03:00","updated_at":"2021-11-25T15:41:21.000+03:00","coordinates":[],"layers":[{"id":26,"building_floor_id":3,"position":1,"kind":"rooms","created_at":"2021-11-17T09:03:50.159+03:00","updated_at":"2021-11-17T09:03:50.166+03:00","file":{"id":31,"content_type":"application/octet-stream","filename":"Room.geojson","url":"https://d1m6d407onyqpz.cloudfront.net/rails/active_storage/blobs/proxy/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBLZz09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--0cc9cd18eba09ec10930a9c312e292b8c98cb41a/Room.geojson","created_at":"2021-11-17T09:03:50.000+03:00"}},{"id":27,"building_floor_id":3,"position":2,"kind":"corridors","created_at":"2021-11-17T09:04:11.571+03:00","updated_at":"2021-11-17T09:04:14.417+03:00","file":{"id":32,"content_type":"application/octet-stream","filename":"Corridor.geojson","url":"https://d1m6d407onyqpz.cloudfront.net/rails/active_storage/blobs/proxy/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBLdz09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--11bf688d6fc5ba3d2012ecb3901da40f9e68ad70/Corridor.geojson","created_at":"2021-11-17T09:04:11.000+03:00"}},{"id":28,"building_floor_id":3,"position":3,"kind":"doors","created_at":"2021-11-17T09:04:21.525+03:00","updated_at":"2021-11-17T09:04:25.159+03:00","file":{"id":33,"content_type":"application/octet-stream","filename":"Door.geojson","url":"https://d1m6d407onyqpz.cloudfront.net/rails/active_storage/blobs/proxy/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBMQT09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--c1e0d90074c6b7dc205f7fdc9165bc9a499deb50/Door.geojson","created_at":"2021-11-17T09:04:21.000+03:00"}},{"id":29,"building_floor_id":3,"position":4,"kind":"be","created_at":"2021-11-17T09:04:32.922+03:00","updated_at":"2021-11-17T09:04:36.516+03:00","file":{"id":34,"content_type":"application/octet-stream","filename":"Furniture.geojson","url":"https://d1m6d407onyqpz.cloudfront.net/rails/active_storage/blobs/proxy/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBMUT09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--642dfdffb08e40aa38cf88398f0eb17787f6b2a1/Furniture.geojson","created_at":"2021-11-17T09:04:32.000+03:00"}},{"id":30,"building_floor_id":3,"position":5,"kind":"outlayer","created_at":"2021-11-17T09:04:43.007+03:00","updated_at":"2021-11-17T09:04:47.532+03:00","file":{"id":35,"content_type":"application/octet-stream","filename":"Outline.geojson","url":"https://d1m6d407onyqpz.cloudfront.net/rails/active_storage/blobs/proxy/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBMZz09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--5ef0d6589e8cbba679116c69640e7382d78705e7/Outline.geojson","created_at":"2021-11-17T09:04:43.000+03:00"}},{"id":31,"building_floor_id":3,"position":6,"kind":"walls","created_at":"2021-11-17T09:04:54.652+03:00","updated_at":"2021-11-17T09:05:00.335+03:00","file":{"id":36,"content_type":"application/octet-stream","filename":"Wall.geojson","url":"https://d1m6d407onyqpz.cloudfront.net/rails/active_storage/blobs/proxy/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBMdz09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--c2cad63e99e8f65d2ff1a87b90d67b35dfcdd9f0/Wall.geojson","created_at":"2021-11-17T09:04:54.000+03:00"}},{"id":32,"building_floor_id":3,"position":7,"kind":"other","created_at":"2021-11-17T09:05:28.899+03:00","updated_at":"2021-11-17T09:05:28.905+03:00","file":{"id":37,"content_type":"application/octet-stream","filename":"Wall.geojson","url":"https://d1m6d407onyqpz.cloudfront.net/rails/active_storage/blobs/proxy/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBNQT09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--bbed3dbe96653f4f3e482d67e166a7332a41e797/Wall.geojson","created_at":"2021-11-17T09:05:28.000+03:00"}}]}},{"building_floor":{"id":2,"building_id":2,"name":"G","configured":true,"created_at":"2021-11-17T08:52:07.000+03:00","updated_at":"2021-11-28T09:10:25.000+03:00","coordinates":[],"layers":[{"id":14,"building_floor_id":2,"position":1,"kind":"walls","created_at":"2021-11-17T08:52:07.137+03:00","updated_at":"2021-11-17T08:52:07.143+03:00","file":{"id":19,"content_type":"application/octet-stream","filename":"Wall.geojson","url":"https://d1m6d407onyqpz.cloudfront.net/rails/active_storage/blobs/proxy/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBIZz09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--d7e057ed367373ae9333e306c82eb0cb00efeed1/Wall.geojson","created_at":"2021-11-17T08:52:07.000+03:00"}},{"id":15,"building_floor_id":2,"position":2,"kind":"corridors","created_at":"2021-11-17T08:52:42.025+03:00","updated_at":"2021-11-17T08:52:45.035+03:00","file":{"id":20,"content_type":"application/octet-stream","filename":"Corridor.geojson","url":"https://d1m6d407onyqpz.cloudfront.net/rails/active_storage/blobs/proxy/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBIdz09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--bbae4ad9852c90a4b3e7d8ce41f9bec78f920a64/Corridor.geojson","created_at":"2021-11-17T08:52:42.000+03:00"}},{"id":16,"building_floor_id":2,"position":3,"kind":"be","created_at":"2021-11-17T08:52:54.823+03:00","updated_at":"2021-11-17T08:52:57.726+03:00","file":{"id":21,"content_type":"application/octet-stream","filename":"Furniture.geojson","url":"https://d1m6d407onyqpz.cloudfront.net/rails/active_storage/blobs/proxy/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBJQT09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--5a6d6f32de1a32b8080eb14b51e776b5ef764ce4/Furniture.geojson","created_at":"2021-11-17T08:52:54.000+03:00"}},{"id":17,"building_floor_id":2,"position":4,"kind":"doors","created_at":"2021-11-17T08:53:05.584+03:00","updated_at":"2021-11-17T08:53:08.799+03:00","file":{"id":22,"content_type":"application/octet-stream","filename":"Door.geojson","url":"https://d1m6d407onyqpz.cloudfront.net/rails/active_storage/blobs/proxy/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBJUT09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--33ede2c96dde3e807956088f6284cf8a8012e7fc/Door.geojson","created_at":"2021-11-17T08:53:05.000+03:00"}},{"id":18,"building_floor_id":2,"position":5,"kind":"rooms","created_at":"2021-11-17T08:53:18.119+03:00","updated_at":"2021-11-17T08:53:25.643+03:00","file":{"id":23,"content_type":"application/octet-stream","filename":"Room.geojson","url":"https://d1m6d407onyqpz.cloudfront.net/rails/active_storage/blobs/proxy/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBJZz09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--95a0c760b951cbcd0ef99961d12df7fc9d2a65e8/Room.geojson","created_at":"2021-11-17T08:53:18.000+03:00"}},{"id":21,"building_floor_id":2,"position":7,"kind":"street","created_at":"2021-11-17T08:55:11.313+03:00","updated_at":"2021-11-17T09:00:11.221+03:00","file":{"id":26,"content_type":"application/octet-stream","filename":"Road.geojson","url":"https://d1m6d407onyqpz.cloudfront.net/rails/active_storage/blobs/proxy/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBKUT09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--0f3fdab992b351c73bf3f8de61decfa658fc5100/Road.geojson","created_at":"2021-11-17T08:55:11.000+03:00"}},{"id":22,"building_floor_id":2,"position":8,"kind":"garden","created_at":"2021-11-17T08:55:31.323+03:00","updated_at":"2021-11-17T08:57:13.233+03:00","file":{"id":27,"content_type":"application/octet-stream","filename":"Garden.geojson","url":"https://d1m6d407onyqpz.cloudfront.net/rails/active_storage/blobs/proxy/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBKZz09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--5ea92ac949ee6ddfbbc5b4a747637cb402ee313a/Garden.geojson","created_at":"2021-11-17T08:55:31.000+03:00"}},{"id":23,"building_floor_id":2,"position":9,"kind":"sidewalk","created_at":"2021-11-17T08:55:45.779+03:00","updated_at":"2021-11-17T08:57:13.235+03:00","file":{"id":28,"content_type":"application/octet-stream","filename":"Side Walk.geojson","url":"https://d1m6d407onyqpz.cloudfront.net/rails/active_storage/blobs/proxy/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBKdz09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--1f4070d759b1f81eaa87264e2fa8d912396eba86/Side%20Walk.geojson","created_at":"2021-11-17T08:55:45.000+03:00"}},{"id":24,"building_floor_id":2,"position":6,"kind":"arrows","created_at":"2021-11-17T09:01:12.731+03:00","updated_at":"2021-11-17T09:01:22.926+03:00","file":{"id":29,"content_type":"application/octet-stream","filename":"Road Arrows and Line.geojson","url":"https://d1m6d407onyqpz.cloudfront.net/rails/active_storage/blobs/proxy/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBLQT09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--6676f3340953dfb65808a523212d77dd35fb7283/Road%20Arrows%20and%20Line.geojson","created_at":"2021-11-17T09:01:12.000+03:00"}},{"id":25,"building_floor_id":2,"position":11,"kind":"other","created_at":"2021-11-17T09:02:12.250+03:00","updated_at":"2021-11-17T09:02:12.258+03:00","file":{"id":30,"content_type":"application/octet-stream","filename":"Wall.geojson","url":"https://d1m6d407onyqpz.cloudfront.net/rails/active_storage/blobs/proxy/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBLUT09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--73dca4accd19480e7054149a8975f4b70d55b418/Wall.geojson","created_at":"2021-11-17T09:02:12.000+03:00"}},{"id":39,"building_floor_id":2,"position":11,"kind":"outlayer","created_at":"2021-11-25T12:01:00.159+03:00","updated_at":"2021-11-25T12:36:54.437+03:00","file":{"id":496,"content_type":"application/octet-stream","filename":"Outline.geojson","url":"https://d1m6d407onyqpz.cloudfront.net/rails/active_storage/blobs/proxy/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBaEFDIiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--0c722df4dea1acd2db3b41929767996a585f2ee6/Outline.geojson","created_at":"2021-11-25T12:01:00.000+03:00"}}]}},{"building_floor":{"id":1,"building_id":2,"name":"-1","configured":true,"created_at":"2021-11-17T08:42:41.000+03:00","updated_at":"2021-11-24T00:17:23.000+03:00","coordinates":[],"layers":[{"id":8,"building_floor_id":1,"position":2,"kind":"rooms","created_at":"2021-11-17T08:45:25.597+03:00","updated_at":"2021-11-17T08:45:30.796+03:00","file":{"id":13,"content_type":"application/octet-stream","filename":"Room.geojson","url":"https://d1m6d407onyqpz.cloudfront.net/rails/active_storage/blobs/proxy/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBHQT09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--177ecef90eae2458100234bf8677dee33863c39e/Room.geojson","created_at":"2021-11-17T08:45:25.000+03:00"}},{"id":9,"building_floor_id":1,"position":3,"kind":"corridors","created_at":"2021-11-17T08:45:55.013+03:00","updated_at":"2021-11-17T08:46:00.519+03:00","file":{"id":14,"content_type":"application/octet-stream","filename":"Corridor.geojson","url":"https://d1m6d407onyqpz.cloudfront.net/rails/active_storage/blobs/proxy/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBHUT09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--5e085eb28c6c005f79800c3c1f4ef54ce00b1c2c/Corridor.geojson","created_at":"2021-11-17T08:45:55.000+03:00"}},{"id":10,"building_floor_id":1,"position":4,"kind":"doors","created_at":"2021-11-17T08:47:50.686+03:00","updated_at":"2021-11-17T08:47:56.638+03:00","file":{"id":15,"content_type":"application/octet-stream","filename":"Door.geojson","url":"https://d1m6d407onyqpz.cloudfront.net/rails/active_storage/blobs/proxy/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBHZz09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--df95bf5a3c0171236219bcaf5ac499216bbb5b3b/Door.geojson","created_at":"2021-11-17T08:47:50.000+03:00"}},{"id":11,"building_floor_id":1,"position":5,"kind":"be","created_at":"2021-11-17T08:48:11.537+03:00","updated_at":"2021-11-17T08:48:17.305+03:00","file":{"id":16,"content_type":"application/octet-stream","filename":"Furniture.geojson","url":"https://d1m6d407onyqpz.cloudfront.net/rails/active_storage/blobs/proxy/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBHdz09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--818a1e32002700752a979e87c5f7ef2946136f8a/Furniture.geojson","created_at":"2021-11-17T08:48:11.000+03:00"}},{"id":12,"building_floor_id":1,"position":6,"kind":"outlayer","created_at":"2021-11-17T08:48:29.262+03:00","updated_at":"2021-11-17T08:48:34.706+03:00","file":{"id":17,"content_type":"application/octet-stream","filename":"Outline.geojson","url":"https://d1m6d407onyqpz.cloudfront.net/rails/active_storage/blobs/proxy/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBIQT09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--ada43010b9e32a69f242b3eca75d43d855da17cb/Outline.geojson","created_at":"2021-11-17T08:48:29.000+03:00"}},{"id":13,"building_floor_id":1,"position":1,"kind":"walls","created_at":"2021-11-17T08:49:16.711+03:00","updated_at":"2021-11-17T08:49:29.580+03:00","file":{"id":18,"content_type":"application/octet-stream","filename":"Wall.geojson","url":"https://d1m6d407onyqpz.cloudfront.net/rails/active_storage/blobs/proxy/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBIUT09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--1e423eaaa5e0d11b6201e870ae73263014d1849e/Wall.geojson","created_at":"2021-11-17T08:49:16.000+03:00"}}]}}]'
            ; var fixed_floors = '[{"building_floors":[{"id":7,"building_id":2,"name":"7","configured":true,"created_at":"2021-11-17T09:09:50.000+03:00","updated_at":"2021-11-17T09:09:50.000+03:00"},{"id":6,"building_id":2,"name":"6","configured":true,"created_at":"2021-11-17T09:09:17.000+03:00","updated_at":"2021-11-17T09:09:17.000+03:00"},{"id":5,"building_id":2,"name":"5","configured":true,"created_at":"2021-11-17T09:08:41.000+03:00","updated_at":"2021-11-17T09:08:41.000+03:00"},{"id":4,"building_id":2,"name":"4","configured":true,"created_at":"2021-11-17T09:06:39.000+03:00","updated_at":"2021-11-17T09:08:11.000+03:00"},{"id":3,"building_id":2,"name":"1","configured":true,"created_at":"2021-11-17T09:03:50.000+03:00","updated_at":"2021-11-25T15:41:21.000+03:00"},{"id":2,"building_id":2,"name":"G","configured":true,"created_at":"2021-11-17T08:52:07.000+03:00","updated_at":"2021-11-28T09:10:25.000+03:00"},{"id":1,"building_id":2,"name":"-1","configured":true,"created_at":"2021-11-17T08:42:41.000+03:00","updated_at":"2021-11-24T00:17:23.000+03:00"}]}]'
            ; var fixed_building = '{"buildings":[{"id":2,"application_id":3,"name":"Burjeel Medical City","address":"Abu Dhabi, Abu Dhabi, United Arab Emirates","coordinate":{"latitude":"24.35456233751691","longitude":"54.53880166798317"}}]}'
            ; var shape_outline = '{"type":"FeatureCollection","features":[{"id":997,"type":"Feature","properties":{"title":"Building shape","icon":"","icon_url":"","Center":["54.53877952883286","24.35448642893815"],"Level":0,"Color":"#ffffff"},"geometry":{"coordinates":[[["54.53863027255579","24.35508575303443"],["54.53864165423533","24.35507699093198"],["54.53866076465968","24.35506524589921"],["54.53868046764896","24.3550565727483"],["54.53870062583434","24.35505012294281"],["54.53873050214324","24.35504600387716"],["54.53875784999306","24.3550468622381"],["54.53877824909639","24.35504973820857"],["54.5387955992577","24.35505380968821"],["54.53881610203059","24.35506252215748"],["54.53883524233021","24.355073198496"],["54.53885369461193","24.35508754458873"],["54.53886144124476","24.35509521606956"],["54.53906584263248","24.3549245954093"],["54.53910608075986","24.35494280485321"],["54.53916412560426","24.3549647824866"],["54.53916673891106","24.35495876048161"],["54.53915288338769","24.35495460649149"],["54.53925675869149","24.35486887837619"],["54.53926048664056","24.35488110566419"],["54.53926670604233","24.35487980944779"],["54.53925828371897","24.3548519754351"],["54.53924657089513","24.35481908493234"],["54.53923280549338","24.35478782586171"],["54.53943878885559","24.35461791176412"],["54.53942651827944","24.35460537807627"],["54.53941313936571","24.35458579160426"],["54.53940299620101","24.35456439108241"],["54.53939808831441","24.35454303047446"],["54.53939498190424","24.3545211449793"],["54.53939634143322","24.3544998767052"],["54.53939970159652","24.35448264992516"],["54.53940558567331","24.35446765899677"],["54.53941570358472","24.35444719246336"],["54.53943145822376","24.35442710847328"],["54.53945026546467","24.3544091673877"],["54.53926384207165","24.35422326561111"],["54.53927518171164","24.35420630285488"],["54.53929463825159","24.35416587649902"],["54.53930876579091","24.35413413001463"],["54.53930209469971","24.35413301933673"],["54.53929756930529","24.35414478112767"],["54.53920322296705","24.35405132336722"],["54.53921679711842","24.35404762241723"],["54.53921622654602","24.3540426376186"],["54.53911427881872","24.35407355074096"],["54.53892887209889","24.3538867005891"],["54.53891681347412","24.35389651271511"],["54.53889651082159","24.35390869400189"],["54.53885985546341","24.35392278425573"],["54.53883928924276","24.35392590753857"],["54.53882431094971","24.35392739958075"],["54.53880221957391","24.35392640887807"],["54.53878147157513","24.35392427770816"],["54.53876419303907","24.35391891514736"],["54.53874419886114","24.35391111257067"],["54.53872509625251","24.35390029901386"],["54.53870612590651","24.35388458578616"],["54.53869852096619","24.35387764180673"],["54.53857500147462","24.35398211129106"],["54.5385502300287","24.35395797088012"],["54.53848939985622","24.3540089048878"],["54.53851218975319","24.35403184107933"],["54.53849402819085","24.35404859819543"],["54.53846608690057","24.3540355950081"],["54.53843848602602","24.35402401767405"],["54.53839587273512","24.35400867290716"],["54.5383939763735","24.35401457310641"],["54.53840752095726","24.35401898233643"],["54.53830349027456","24.3541053055354"],["54.53829969116762","24.35409212562574"],["54.53829338520322","24.35409293552509"],["54.53830023897657","24.35411758021691"],["54.53831532096101","24.35415860018151"],["54.53832789774438","24.35418532265673"],["54.5381204142391","24.35435506849531"],["54.53813332467871","24.35436792901011"],["54.53814402888383","24.35438377497563"],["54.53815328181173","24.35440167157664"],["54.53815988849834","24.35441824089247"],["54.53816264277378","24.35444217957926"],["54.53816259602386","24.35446453341355"],["54.53816007847678","24.35448276002481"],["54.53815472341594","24.35450395995366"],["54.53814732950212","24.35451901827689"],["54.53813839843562","24.35453416357439"],["54.53812576406102","24.35454866506977"],["54.53810879220106","24.35456430404281"],["54.53829569166513","24.35474922336845"],["54.53828826058663","24.35476318537265"],["54.53827958057647","24.35477764656771"],["54.53827044401055","24.35479571402722"],["54.53825812885754","24.35482078505835"],["54.53825185587397","24.35483817823989"],["54.53825757973271","24.3548398939225"],["54.53826237111792","24.35482718055735"],["54.53835718398008","24.3549220857895"],["54.53834222969451","24.35492514204917"],["54.5383442263886","24.35493157808511"],["54.53838061663382","24.35492151688337"],["54.53840722126844","24.35491329934403"],["54.53844613695225","24.35489950653661"],["54.53863027255579","24.35508575303443"]]],"type":"Polygon"}}]}'
            ; var followes = '{"type":"FeatureCollection","features":[{"id":998,"type":"Feature","properties":{"title":"F1","icon":"","icon_url":"","Center":["54.53902600534079","24.35473078325195"],"Level":7,"Color":"#ffffff"},"geometry":{"coordinates":[[["54.53878388875933","24.35457621469833"],["54.53879630701964","24.35465092386721"],["54.5388211871968","24.35472546140612"],["54.53885233630204","24.35476851796906"],["54.53888840154676","24.35481497681036"],["54.53895528567114","24.35486256913242"],["54.53901015870571","24.35489400617527"],["54.53906079157395","24.35492215772837"],["54.53916387107103","24.35496411607721"],["54.53916639533662","24.35495781546935"],["54.53915361711853","24.35495457101391"],["54.53925681735791","24.35486991425011"],["54.53925974434646","24.35488073401136"],["54.53926812192225","24.35487926783125"],["54.53924708285712","24.35482505372651"],["54.53922922967107","24.35477941380594"],["54.53919027009638","24.35470762345957"],["54.53915862161963","24.35466359956882"],["54.53914660671327","24.35464942195664"],["54.53908758618133","24.35459108901783"],["54.53900972158772","24.35454934544883"],["54.53887863651565","24.35449745042669"],["54.53886993444948","24.35452393634597"],["54.5388563737082","24.35454336239856"],["54.5388428320295","24.35455623376524"],["54.53881729784038","24.35457110032051"],["54.53879450492062","24.35457556795475"],["54.53878388875933","24.35457621469833"]]],"type":"Polygon"}},{"id":999,"type":"Feature","properties":{"title":"F2","icon":"","icon_url":"","Center":["54.53905262603365","24.35426212503486"],"Level":7,"Color":"#ffffff"},"geometry":{"coordinates":[[["54.5387955691063","24.35439535029803"],["54.53883823959444","24.35432556177267"],["54.53888916570807","24.35425181375393"],["54.53894390986073","24.35418208422557"],["54.5389940719997","24.35414483104945"],["54.53901611549364","24.35412943947522"],["54.53911273167398","24.35407706577996"],["54.53921694353994","24.35404132698952"],["54.53921881571412","24.35404958585379"],["54.53920563560024","24.35405102131003"],["54.53929866268837","24.35414372313107"],["54.53930201445687","24.35413373989797"],["54.539309682961","24.35413627732757"],["54.53926249530576","24.35422754305262"],["54.53921476859821","24.35429343467383"],["54.53917055486576","24.35434571633751"],["54.53912889475291","24.35438376102499"],["54.53907709504753","24.35441950617732"],["54.53897910676832","24.3544561488844"],["54.53888208239633","24.3544829230802"],["54.53887998445492","24.35446641346397"],["54.5388707844956","24.35444436931208"],["54.53885934805942","24.35442931393992"],["54.53884214477068","24.35441498032016"],["54.53882875657411","24.35440516519175"],["54.5387955691063","24.35439535029803"]]],"type":"Polygon"}},{"id":1001,"type":"Feature","properties":{"title":"F4","icon":"","icon_url":"","Center":["54.53853454543459","24.35424171765698"],"Level":7,"Color":"#ffffff"},"geometry":{"coordinates":[[["54.53829278677267","24.35409454090449"],["54.53830841409271","24.3541418836232"],["54.53832909885634","24.35418818727459"],["54.53837660814338","24.35426745728923"],["54.53843337559016","24.3543408093915"],["54.5384920414904","24.35439392037057"],["54.53857540767919","24.3544370456715"],["54.53868069760765","24.35447567907008"],["54.53868569505494","24.35445722217247"],["54.53869435912279","24.35444208470598"],["54.53870807886966","24.35442539590004"],["54.53872069689793","24.35441537007578"],["54.538741467835","24.3544050647959"],["54.53875972152147","24.35439860892372"],["54.5387763040965","24.35439676848421"],["54.53876255807282","24.35435643746523"],["54.53874042071794","24.35429656220032"],["54.53871920891586","24.35426050600729"],["54.53869771330062","24.35422368217293"],["54.53864520127127","24.35416133220127"],["54.53849410316727","24.35404752210975"],["54.53839722524071","24.35400775624389"],["54.53839303335007","24.35401519652883"],["54.53840626135166","24.35401900093566"],["54.53830449216809","24.35410458922615"],["54.53830079378523","24.35409204854092"],["54.53829278677267","24.35409454090449"]]],"type":"Polygon"}},{"id":1000,"type":"Feature","properties":{"title":"F3","icon":"","icon_url":"","Center":["54.53850696825451","24.35470868907411"],"Level":7,"Color":"#ffffff"},"geometry":{"coordinates":[[["54.53876549362826","24.3545735693277"],["54.53873455794601","24.35464445102842"],["54.53870032459201","24.35468871590723"],["54.53867940249001","24.3547159569096"],["54.53862805382244","24.35476996472276"],["54.53855263288366","24.35482214383407"],["54.53844983203959","24.35489878201141"],["54.53838453605806","24.35491783352444"],["54.53834240612721","24.35493051145822"],["54.53834035918564","24.35492455319958"],["54.53835392863786","24.35492178421495"],["54.53826101980002","24.35482909062324"],["54.53825765684047","24.3548402965107"],["54.53824844288076","24.35483826324101"],["54.53826271846307","24.35480628859922"],["54.53829359158726","24.354748450725"],["54.53829887978122","24.35473831690327"],["54.53833332629165","24.35470105419934"],["54.53840729298679","24.35462178224341"],["54.53851064238759","24.35454292425409"],["54.53857896441781","24.3545193626302"],["54.53867821530898","24.35448686669"],["54.53868105820678","24.35450713580386"],["54.53868909400654","24.35452331247743"],["54.53870195801903","24.35454355445519"],["54.53871462434506","24.35455508200977"],["54.53873613814613","24.35456637371971"],["54.53876549362826","24.3545735693277"]]],"type":"Polygon"}}]}';
        ; var walls_outside = '{"type":"FeatureCollection","features":[{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[54.537900388240814,24.355808003278593],[54.538201466202736,24.355819915329892],[54.53819911926985,24.355864509153033],[54.538393914699554,24.355873366828373],[54.5383882150054,24.355962859858124],[54.53900545835494,24.355992181792683],[54.5390098169446,24.35589871810261],[54.539185501635075,24.3559060485906],[54.539188519120216,24.3558538188544],[54.53950334340334,24.355868479835166],[54.53966226428747,24.353064536370272],[54.53806534409523,24.352998865925983],[54.537988230586045,24.354364498710684],[54.53798118978739,24.3543648041514],[54.53806132078171,24.352993062489734],[54.539667293429375,24.35305934382475],[54.539508037269115,24.355873366828373],[54.53919589519501,24.355859011285283],[54.539191871881485,24.355910324708397],[54.53901551663875,24.35590299422066],[54.539009146392345,24.35599645790757],[54.53838352113962,24.355967441410858],[54.53838922083378,24.355877642947277],[54.5381947606802,24.35586817439808],[54.53819677233696,24.355826634948095],[54.537896029651165,24.35581227939971],[54.537973143160336,24.354502557836675],[54.53798018395901,24.35450225239629],[54.537900388240814,24.355808003278593]]]}}]}'
            ; var gate_polar = '{"type":"FeatureCollection","features":[{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[54.537971802055836,24.354512331928376],[54.53798320144414,24.35451294280908],[54.537982530891895,24.35452424410163],[54.53797113150358,24.3545239386613],[54.537971802055836,24.354512331928376]]]}},{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[54.53797884285449,24.35437671633852],[54.53797917813063,24.354364498710684],[54.5379889011383,24.3543648041514],[54.537988230586045,24.354377327219883],[54.53797884285449,24.35437671633852]]]}}]}';
        var gate_y = '{"type":"FeatureCollection","features":[{"type":"Feature","properties":{"stroke":"#555555","stroke-width":2,"stroke-opacity":1,"fill":"#555555","fill-opacity":0.5},"geometry":{"type":"Polygon","coordinates":[[[54.537971802055836,24.35451202648802],[54.53797884285449,24.35437671633852],[54.53798856586218,24.354377021779207],[54.53798320144414,24.354512637368735],[54.537971802055836,24.35451202648802]]]}}]}';



        var building = turf.polygon([[
            [50.13763203066759, 26.30920839751299],
            [50.13860082036348, 26.308241299426584],
            [50.13817134791074, 26.30806452287021],
            [50.137316489354646, 26.308782938264073],
            [50.13763203066759, 26.30920839751299]
        ]]);


        function getinfo() {
            for (var i = 0; i < qjson.ranges.length; i++) {
                var lng = parseFloat(qjson.ranges[i].location.lng);
                var lat = parseFloat(qjson.ranges[i].location.lat);
                //console.log("lng : "+lng+" , lat : "+lat);
                if (!(isNaN(lng)) && !(isNaN(lat))) {
                    var points = turf.points([[lng, lat]]);
                    var ptsWithin = turf.pointsWithinPolygon(points, building);
                    if (ptsWithin.features.length > 0) {
                        var z = qjson.ranges[i].proximity_id.split("+")
                    }
                }

            }
        }



        var other_buildings = '{"type":"FeatureCollection","features":[{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[50.13686059042812,26.3107032115662],[50.1371480897069,26.31089826364199],[50.137288402766,26.3107451372712],[50.13700224459172,26.31054843195036],[50.13686059042812,26.3107032115662]]]}},{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[50.13602413500007,26.31333009700006],[50.13652340900006,26.31370449200006],[50.13656597100004,26.31365986000003],[50.13658729500003,26.31363751600003],[50.13662936100008,26.31359338900006],[50.13635989700003,26.31339132500006],[50.13638478100006,26.31336523200003],[50.13637364800007,26.31335688200005],[50.13645475000004,26.31327185000004],[50.13647943100005,26.31329038200005],[50.13650315000007,26.31326551000007],[50.13647834200003,26.31324691900005],[50.13648780100004,26.31323699900003],[50.13639875000007,26.31317018600004],[50.13635268500008,26.31321849100005],[50.13636009500004,26.31322404700006],[50.13631909300005,26.31326702800004],[50.13626059000006,26.31322315800003],[50.13620965700005,26.31327656800005],[50.13613008700003,26.31321899500006],[50.13609124000004,26.31325973000003],[50.13604829600007,26.31322642000004],[50.13601892500003,26.31325721800005],[50.13606248200006,26.31328988700006],[50.13602413500007,26.31333009700006]]]}},{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[50.13625675812364,26.31306274861409],[50.13636957854033,26.31314224052347],[50.13666294515134,26.31283043357203],[50.13667820021511,26.31284140318022],[50.13662908226252,26.31289249449239],[50.13674860820175,26.3129761940345],[50.13688858598471,26.31283133518369],[50.1367685571313,26.31274958903028],[50.13673570007087,26.31278370002411],[50.13671625405551,26.31277032611141],[50.1368166692555,26.31266258341025],[50.13669546693564,26.31258534520576],[50.13625675812364,26.31306274861409]]]}},{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[50.13446873053909,26.30847166021509],[50.13477902859449,26.30846880500403],[50.13477902859449,26.30835023854522],[50.13472001999617,26.30835114019177],[50.13471968472005,26.30830004687719],[50.13458456844092,26.30829914523027],[50.13458423316479,26.30834963744754],[50.1344700716436,26.30834888607541],[50.13446873053909,26.30847166021509]]]}},{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[50.13520332053305,26.30812362449436],[50.13535302132369,26.3081231736702],[50.13535117730499,26.30785403133941],[50.13519929721952,26.30785297941393],[50.13519980013371,26.30790001550051],[50.13518001884223,26.30790031605051],[50.13518055111378,26.30798566474134],[50.1352016441524,26.30798537167272],[50.13520332053305,26.30812362449436]]]}},{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[50.13536693528295,26.30808049564269],[50.135996080935,26.3080761376742],[50.13599256053568,26.30794855431742],[50.13536391779781,26.3079533631155],[50.13536693528295,26.30808049564269]]]}},{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[50.13605391606689,26.30806336431737],[50.13621501624586,26.30804457996651],[50.13618785887957,26.30789866302543],[50.13602390885354,26.30791895014975],[50.13605391606689,26.30806336431737]]]}},{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[50.13648239895702,26.30800505768238],[50.13666244223715,26.30797650545353],[50.1366369612515,26.30783855300655],[50.13645322993399,26.30786455059355],[50.13648239895702,26.30800505768238]]]}},{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[50.13669529929758,26.3079715463815],[50.13687115162611,26.30794509799367],[50.13684650883079,26.30781315651423],[50.13666780665518,26.30783900383183],[50.13669529929758,26.3079715463815]]]}},{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[50.13690534979105,26.30793863617071],[50.13708673417568,26.3079117369504],[50.13706779107452,26.30778475451325],[50.13688104227186,26.30780894881081],[50.13690534979105,26.30793863617071]]]}},{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[50.13891382142901,26.3082170953303],[50.13904541730881,26.30821634395731],[50.13904608786107,26.30804773573767],[50.13891616836191,26.30804653353915],[50.13891382142901,26.3082170953303]]]}},{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[50.13911616057158,26.30821664450652],[50.13924742117525,26.30821649423193],[50.13924809172751,26.30805059095914],[50.13911632820965,26.30805044068432],[50.13911616057158,26.30821664450652]]]}},{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[50.13625793159008,26.30803811814913],[50.13644685968757,26.30800971620327],[50.13642221689224,26.30786740581952],[50.13622859492898,26.30789580780025],[50.13625793159008,26.30803811814913]]]}},{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[50.1351223513484,26.30852786277665],[50.13512284258789,26.30834372969841],[50.13501355424524,26.30834227400056],[50.13501405177042,26.30829905233413],[50.1347840577364,26.30829794303436],[50.13478439301252,26.30847256186069],[50.13498689979316,26.30847075856952],[50.13498689979316,26.30852816332502],[50.1351223513484,26.30852786277665]]]}},{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[50.13667585328223,26.31091734807246],[50.13681868091226,26.31096182830761],[50.13688523322345,26.31081020473316],[50.13673754408956,26.310761216301],[50.13667585328223,26.31091734807246]]]}}]}';

        var psy_building = '{"type":"FeatureCollection","features":[{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[50.13803030000003,26.30881331400008],[50.13805081000004,26.30883136400007],[50.13806981800008,26.30881523900007],[50.13808596900003,26.30880951400008],[50.13810220500005,26.30880252800006],[50.13812191200003,26.30879217700005],[50.13813814800005,26.30878185600006],[50.13814966300004,26.30877337000004],[50.13816400500008,26.30876115900003],[50.13817834457409,26.30874644325617],[50.13819372800003,26.30872750400005],[50.13820402700003,26.30871154400006],[50.13820733800003,26.30870561900003],[50.13821162700003,26.30869256500006],[50.13823232100003,26.30867739100006],[50.13821181100008,26.30865934100007],[50.13829578900004,26.30858810300004],[50.13828890700006,26.30858204700008],[50.13834800500007,26.30852384200006],[50.13841148300003,26.30845603300003],[50.13842969400008,26.30843277200006],[50.13844464200008,26.30840480400008],[50.13845745700007,26.30836734400004],[50.13849872600008,26.30824201800005],[50.13850015100007,26.30818881700003],[50.13848381300005,26.30815717000007],[50.13843509800006,26.30814570000007],[50.13840572200007,26.30815692500005],[50.13839961600007,26.30817102800006],[50.13841223100007,26.30817559400004],[50.13840901600003,26.30818540600007],[50.13812814600004,26.30818454900003],[50.13812408100006,26.30843467600005],[50.13808426400004,26.30843751300006],[50.13808235200003,26.30854841600007],[50.13807346000004,26.30854844900006],[50.13807285800004,26.30858342000005],[50.13804496000006,26.30858333500004],[50.13801060500003,26.30861277600008],[50.13800789700008,26.30861039300004],[50.13797749500003,26.30863618300004],[50.13798088200008,26.30863747400008],[50.13794541800007,26.30866777600005],[50.13794500300003,26.30869187800005],[50.13790452400008,26.30869175500004],[50.13790441000003,26.30869839900004],[50.13777595400006,26.30869904800005],[50.13777194300008,26.30873317900006],[50.13748242700007,26.30873230400005],[50.13747836500005,26.30896835900006],[50.13741728300005,26.30898260800007],[50.13743680500005,26.30904931200007],[50.13756423100006,26.30902031500006],[50.13772758300007,26.30898314300004],[50.13776074800006,26.30901233000003],[50.13779682800003,26.30897934600006],[50.13793455900003,26.30889452900004],[50.13803030000003,26.30881331400008]]]}}]}';

        var building_50 = '{"type":"FeatureCollection","features":[{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[50.13514532100004,26.31095020500004],[50.13549769400004,26.31129253500007],[50.13567921600009,26.31146102800006],[50.13566665900004,26.31147113600008],[50.13568437100008,26.31148756200008],[50.13570553900007,26.31147052400007],[50.13572219400004,26.31148602000008],[50.13570811600005,26.31149735100007],[50.13574238700005,26.31152918100009],[50.13573092400009,26.31153963700007],[50.13574313500004,26.31155100800004],[50.13591881600007,26.31141078200006],[50.13592699900005,26.31141838200006],[50.13592385700008,26.31142261200006],[50.13592245400008,26.31142616100005],[50.13592205100008,26.31143265800006],[50.13592331900009,26.31143717600009],[50.13592850400005,26.31144420100009],[50.13593397700004,26.31144775800005],[50.13593949000006,26.31144958200008],[50.13594661800005,26.31145002900007],[50.13595069600007,26.31144935700007],[50.13595729300005,26.31144651900007],[50.13597596400007,26.31146386000006],[50.13598877900006,26.31146446200006],[50.13599107800007,26.31147128500004],[50.13599513700007,26.31147633600006],[50.13599789000006,26.31147846500005],[50.13600533800007,26.31148171300004],[50.13601173100005,26.31148247900007],[50.13602135500008,26.31148042300004],[50.13602703000004,26.31147668800009],[50.13603158800004,26.31146997000008],[50.13603248000004,26.31146651400008],[50.13605157500007,26.31146741000009],[50.13605280000007,26.31147222900006],[50.13605438200005,26.31147523900006],[50.13605833800005,26.31147972600008],[50.13606371200007,26.31148313900008],[50.13607125900006,26.31148524900005],[50.13607779100005,26.31148516700006],[50.13608402400007,26.31148337700006],[50.13608983000006,26.31147953200008],[50.13609300600007,26.31147557000009],[50.13609517300006,26.31146945700005],[50.13617593600009,26.31147228900005],[50.13617503700004,26.31151723700009],[50.13613291500008,26.31151525900009],[50.13613194100009,26.31156393800007],[50.13617406300006,26.31156591600007],[50.13617271000004,26.31163350700007],[50.13631195800008,26.31164004400006],[50.13631828129292,26.31145035841557],[50.13617451700009,26.31144524800004],[50.13617594300007,26.31141170300009],[50.13619856300005,26.31141284900008],[50.13619863400004,26.31141115400004],[50.13618698500005,26.31141055100005],[50.13618729500007,26.31139499800009],[50.13619690100006,26.31139545400004],[50.13619696600006,26.31139290000005],[50.13619400100004,26.31139276100004],[50.13620097000006,26.31104454200005],[50.13622211000006,26.31102752800007],[50.13586151900006,26.31069261700009],[50.13583854600006,26.31071110700009],[50.13586379900005,26.31073456100006],[50.1355882050095,26.31072162278352],[50.13539652400004,26.31071262400008],[50.13514532100004,26.31095020500004]]]}}]}';

        var dental = '{"type":"FeatureCollection","features":[{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[50.13505150200007,26.31168573600007],[50.13510290300007,26.31163683300003],[50.13512260800007,26.31165567500006],[50.13517815000006,26.31160283000003],[50.13516912800003,26.31159420300003],[50.13517970200007,26.31158414300006],[50.13519256000006,26.31159643800004],[50.13520081500008,26.31158858300006],[50.13520807000003,26.31159552000003],[50.13527013600003,26.31153646700006],[50.13526288200006,26.31152953000003],[50.13527113700007,26.31152167600004],[50.13525827700005,26.31150937800004],[50.13528579400003,26.31148319700003],[50.13527304900003,26.31147494600004],[50.13534577500008,26.31140575000007],[50.13529092100003,26.31135180500007],[50.13526883700007,26.31136879200006],[50.13523108600003,26.31133269500004],[50.13523627800004,26.31132639900005],[50.13523435100007,26.31132455600005],[50.13519239900006,26.31136447100005],[50.13518134600008,26.31135390200007],[50.13520468900003,26.31133178300007],[50.13520923100003,26.31132450500008],[50.13521050700007,26.31131702600004],[50.13520869200005,26.31130922600005],[50.13520379900007,26.31130273600008],[50.13518407600003,26.31128384700003],[50.13518793600008,26.31128017500004],[50.13518177600008,26.31127428500003],[50.13517602700006,26.31127975400006],[50.13499715500006,26.31111027300006],[50.13500276700006,26.31110311900005],[50.13495804600007,26.31106037100006],[50.13494530700007,26.31107248400008],[50.13492075500005,26.31104999200005],[50.13491232100006,26.31105799900007],[50.13492781300005,26.31107281300007],[50.13490617600007,26.31109337200008],[50.13490248300008,26.31108984100007],[50.13488980600005,26.31110188400004],[50.13490207000007,26.31111363000003],[50.13487593300005,26.31113849800005],[50.13485416900005,26.31111768700004],[50.13480787000003,26.31116173800007],[50.13482963400003,26.31118254900003],[50.13471901300005,26.31128780000006],[50.13474512800008,26.31131252200004],[50.13473696800003,26.31132028500008],[50.13473257400005,26.31131285800007],[50.13472379500007,26.31130737300004],[50.13471411500007,26.31130651000007],[50.13470417400003,26.31131022500006],[50.13469681500004,26.31131833000007],[50.13469443900004,26.31132881400004],[50.13469734300003,26.31133814900005],[50.13470268000003,26.31134400300005],[50.13472102900005,26.31136167000006],[50.13471735600007,26.31136516500004],[50.13478112100006,26.31142718800004],[50.13479164700004,26.31141717400004],[50.13485280400005,26.31147565100003],[50.13484992000008,26.31147839600004],[50.13481760300004,26.31144749500004],[50.13463392100005,26.31162225900005],[50.13466030200004,26.31164748400005],[50.13464654300003,26.31166057500008],[50.13467951900003,26.31169210600007],[50.13469327800004,26.31167901500004],[50.13471965900004,26.31170424000004],[50.13472540200007,26.31169877700006],[50.13473552500005,26.31170845600008],[50.13480416100003,26.31164265000007],[50.13479430100006,26.31163322200007],[50.13484933700005,26.31158085800007],[50.13485919700003,26.31159028600007],[50.13488158100006,26.31156898900003],[50.13487172100008,26.31155956100003],[50.13489558500004,26.31153685500005],[50.13505150200007,26.31168573600007]]]}}]}';

        var main_building = '{"type":"FeatureCollection","features":[{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[50.13465544500008,26.31012421600008],[50.13467712200003,26.31012370100007],[50.13468645400008,26.31012154900003],[50.13469192000008,26.31011856100003],[50.13469719000005,26.31011378400007],[50.13470051000007,26.31010889500004],[50.13470255400006,26.31010380200007],[50.13470514100004,26.31011271100005],[50.13470884200007,26.31011836800008],[50.13471358500004,26.31012281300008],[50.13472044800005,26.31012659700008],[50.13472928500005,26.31012856900003],[50.13473534900004,26.31012839300007],[50.13474290300007,26.31012642000008],[50.13475093000005,26.31012161000007],[50.13475758200008,26.31011357100005],[50.13475991800004,26.31010799800004],[50.13476083100005,26.31010357300005],[50.13477802600005,26.31010318300003],[50.13478009600004,26.31011021000006],[50.13478260100004,26.31011461900005],[50.13478697400006,26.31011952900008],[50.13479180300004,26.31012299300005],[50.13479817900003,26.31012570300004],[50.13480042900005,26.31012627200005],[50.13480536600008,26.31012690200004],[50.13481232600003,26.31012642500008],[50.13481773300003,26.31012490600006],[50.13482339600006,26.31012201800007],[50.13482805900003,26.31011825500008],[50.13483149400008,26.31011414500006],[50.13483472900003,26.31010786000008],[50.13483615700005,26.31010186200007],[50.13483837800004,26.31010181100004],[50.13483962500004,26.31010677100005],[50.13484141400005,26.31011076200008],[50.13484495800003,26.31011578200003],[50.13484835400004,26.31011902400008],[50.13485699800003,26.31012383500007],[50.13486621600003,26.31012555000007],[50.13487328000008,26.31012493900005],[50.13488048700003,26.31012249500003],[50.13488536200003,26.31011952200004],[50.13489128900005,26.31011359500008],[50.13489341300004,26.31011028200004],[50.13489572900005,26.31010464800005],[50.13489658700007,26.31010041000008],[50.13493092000004,26.31009963200006],[50.13493308200003,26.31010654200003],[50.13493671800006,26.31011213000005],[50.13493957500003,26.31011499900007],[50.13494443300004,26.31011833800005],[50.13494780100007,26.31011986800007],[50.13495277800007,26.31012123800008],[50.13495800100003,26.31012168700005],[50.13495875100006,26.31012005000003],[50.13501812500004,26.31011870300006],[50.13501816800004,26.31012162200006],[50.13502005400005,26.31012157900006],[50.13501938200005,26.31010663300003],[50.13503237000003,26.31010634000006],[50.13503780000008,26.31011133100003],[50.13503792500006,26.31011966700004],[50.13504664700008,26.31011946900003],[50.13505291500007,26.31012523100003],[50.13505899800003,26.31011919000003],[50.13506773800003,26.31011899100003],[50.13506760900003,26.31011030500003],[50.13509131800004,26.31010976600004],[50.13509144600005,26.31011845300003],[50.13510017800007,26.31011825500008],[50.13510644500008,26.31012401500004],[50.13511253000007,26.31011797300005],[50.13512126000006,26.31011777500004],[50.13512113200005,26.31010908900004],[50.13514720300003,26.31010849800004],[50.13514733100004,26.31011718400004],[50.13515606200008,26.31011698400005],[50.13516233200005,26.31012274600005],[50.13516842300004,26.31011670400005],[50.13517714500006,26.31011650600005],[50.13517701700005,26.31010781900005],[50.13520304000008,26.31010722800005],[50.13520317100006,26.31011591500004],[50.13521190100005,26.31011571700003],[50.13521816100007,26.31012147900003],[50.13522424400003,26.31011543500006],[50.13523298300004,26.31011523900003],[50.13523285400004,26.31010655100005],[50.13525885000007,26.31010596100004],[50.13525898000006,26.31011464700004],[50.13526771200003,26.31011445000007],[50.13527397100006,26.31012021100003],[50.13528006200005,26.31011416900003],[50.13528879400008,26.31011397000003],[50.13528867000008,26.31010563400003],[50.13529290400004,26.31010144300007],[50.13534926800003,26.31010016400006],[50.13534947800008,26.31011428700004],[50.13539173600003,26.31011332500003],[50.13545258700003,26.31016818300003],[50.13547601200003,26.31016765000004],[50.13547676700006,26.31017174500005],[50.13547911500007,26.31017700300004],[50.13548194900005,26.31018062200008],[50.13548650400003,26.31018421900007],[50.13549166400003,26.31018649000004],[50.13549869100007,26.31018749100008],[50.13550495200008,26.31018659400007],[50.13551144800005,26.31018362200007],[50.13551499700003,26.31018074300005],[50.13551871500005,26.31017585200005],[50.13552025000007,26.31017250300005],[50.13552141100007,26.31016661800004],[50.13554484900004,26.31016608700003],[50.13560319300007,26.31010687200007],[50.13560206700004,26.31010491800004],[50.13560172400003,26.31008195700003],[50.13561443300006,26.31007743100003],[50.13612059900004,26.31006598100004],[50.13612100700004,26.31009327700008],[50.1361945474087,26.31009160570895],[50.13619556300006,26.31014067500007],[50.13660220600008,26.31013144100007],[50.13660294700003,26.31018123200005],[50.13698236500005,26.31017261600005],[50.13704947600007,26.31023540400003],[50.13735952300004,26.31022836200003],[50.13735731300005,26.31008006100007],[50.13734982300008,26.30957730700004],[50.13720153900005,26.30957977900005],[50.13719888000003,26.30940131000006],[50.13722412600004,26.30940074400007],[50.13722269700003,26.30930488400003],[50.13712816500015,26.30930574300015],[50.13712719400019,26.30924847600011],[50.13716273200009,26.30924782800008],[50.13716761200016,26.30924554600006],[50.13716998000018,26.30924098400004],[50.13717012900008,26.30911610600004],[50.1372670670001,26.30911214200006],[50.13726927700014,26.3087284880001],[50.13723430500005,26.30872857300006],[50.13723430000005,26.30871979900008],[50.13723856500013,26.30871945800016],[50.13723856000007,26.30870733300009],[50.13725124800004,26.30870710199997],[50.13725123000006,26.30866296300019],[50.13723854100016,26.30866178800017],[50.13723815000003,26.3086614340001],[50.13716974100015,26.30866242100012],[50.13717357069255,26.30862043164212],[50.13687119800005,26.30862594900015],[50.13687118800004,26.30859961400018],[50.13652850700021,26.3086052300003],[50.13652805200007,26.30857745300006],[50.13652336700005,26.30857753900006],[50.13646566800003,26.30857859600008],[50.13646557600003,26.30862003800007],[50.13643515000007,26.30862059400005],[50.13643539900005,26.30850759200007],[50.13599396800004,26.30851566900003],[50.13599387800008,26.30855714500007],[50.13594340200007,26.30855806600005],[50.13594331300004,26.30859844000003],[50.13599378900005,26.30859751700007],[50.13599368300004,26.30864618300007],[50.13596416000007,26.30864672100006],[50.13596357409524,26.30889669043438],[50.13635564500004,26.30888967800007],[50.13635577300005,26.30890546400008],[50.13635899726836,26.30890540510967],[50.13635920586506,26.30921942199081],[50.13628486000005,26.30922111000007],[50.13628500500005,26.30923077300003],[50.13606012300005,26.30923588000008],[50.13606036400006,26.30925201800005],[50.13603011000004,26.30925272300005],[50.13603063100004,26.30928773800003],[50.13601690100006,26.30928805000008],[50.13601598800005,26.30922668700004],[50.13600378500007,26.30922696600004],[50.13600362600005,26.30921621900007],[50.13598252400004,26.30921669900005],[50.13598222100006,26.30915098500003],[50.13499171800004,26.30916059000004],[50.13499120600005,26.30913878100006],[50.13471046462656,26.30914308368679],[50.13471853600004,26.30932889800005],[50.13474985800008,26.30932818800005],[50.13475004400004,26.30934072500003],[50.13451569900008,26.30934604700008],[50.13451797400006,26.30949869200004],[50.13460320900003,26.30949675600005],[50.134639,26.30952989500003],[50.13464104700006,26.30966741400005],[50.13464739700004,26.31005502200003],[50.13465840700007,26.31005477300005],[50.13465865600006,26.31007149400006],[50.13465981100006,26.31010130700003],[50.13465875300005,26.31010133000007],[50.13465885600004,26.31010833300008],[50.13465520900007,26.31010841600005],[50.13465544500008,26.31012421600008]]]}}]}';

        var main_upper = '{"type":"FeatureCollection","features":[{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[50.13647084900003,26.31004797000003],[50.13650737400008,26.31004729000006],[50.13650738600006,26.31004089600003],[50.13681608000007,26.31003514400004],[50.13681603000003,26.31006657100005],[50.13693142300008,26.31006442200004],[50.13693147300006,26.31003299400004],[50.13713807200003,26.31002914400006],[50.13713806200008,26.31003553500006],[50.13717458800005,26.31003485500003],[50.13717475000004,26.30993373900003],[50.13730852900005,26.30993124600008],[50.13730871600006,26.30981401600008],[50.13714799200005,26.30981701100007],[50.13714803900007,26.30978722600003],[50.13706926400005,26.30978869500007],[50.13706937200004,26.30972104700004],[50.13697624300005,26.30972278300004],[50.13697613500005,26.30979043100007],[50.13686630200004,26.30979247700003],[50.13686635400006,26.30975967500007],[50.13673668700005,26.30976209100004],[50.13673663400004,26.30979489300006],[50.13649713400008,26.30979935700003],[50.13649691800003,26.30993465200004],[50.13647505800003,26.30993505900006],[50.13647500900004,26.30996586500004],[50.13647097900008,26.30996593900005],[50.13647084900003,26.31004797000003]]]}},{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[50.13604805061661,26.31006762851374],[50.13612059900004,26.31006598100004],[50.13612100700004,26.31009327700008],[50.13630889356138,26.31009070383789],[50.13630520552397,26.30922873949],[50.13606012300005,26.30923588000008],[50.13606036400006,26.30925201800005],[50.13604772739484,26.30925248268425],[50.13604739100003,26.30946304600008],[50.13604805061661,26.31006762851374]]]}}]}';

        var raster_images = '{"type":"FeatureCollection","features":[{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[55.28831273317338,25.22502157114566],[55.28866410255433,25.22560634089087],[55.28923273086548,25.22533458102702],[55.28889209032059,25.22474253064971]]]}}]}'

    </script>
</body>

</html>